Mix.Task.run("app.start")

ExUnit.start()

# Mimic mocks setup
Mimic.copy(Broadway)
Mimic.copy(Ch)
Mimic.copy(ConfigCat)
Mimic.copy(ConfigCat.User)
Mimic.copy(Date)
Mimic.copy(ExTwilio.Message)
Mimic.copy(Finch)
Mimic.copy(GRPC.Stub)
Mimic.copy(Google.Cloud.Bigquery.Storage.V1.BigQueryWrite.Stub)
Mimic.copy(GoogleApi.BigQuery.V2.Api.Datasets)
Mimic.copy(GoogleApi.BigQuery.V2.Api.Jobs)
Mimic.copy(GoogleApi.BigQuery.V2.Api.Tabledata)
Mimic.copy(GoogleApi.BigQuery.V2.Api.Tables)
Mimic.copy(GoogleApi.CloudResourceManager.V1.Api.Projects)
Mimic.copy(GoogleApi.IAM.V1.Api.Projects)
Mimic.copy(Goth)
Mimic.copy(Phoenix.Token)
Mimic.copy(Stripe.Customer)
Mimic.copy(Stripe.Invoice)
Mimic.copy(Stripe.PaymentMethod)
Mimic.copy(Stripe.Subscription)
Mimic.copy(Stripe.SubscriptionItem.Usage)

Mimic.copy(Logflare.Admin)
Mimic.copy(Logflare.Alerting.AlertsScheduler)
Mimic.copy(Logflare.Auth)
Mimic.copy(Logflare.Backends)
Mimic.copy(Logflare.Backends.Adaptor.BigQueryAdaptor)
Mimic.copy(Logflare.Backends.Adaptor.BigQueryAdaptor.GoogleApiClient)
Mimic.copy(Logflare.Cluster.Utils)
Mimic.copy(Logflare.Backends.Adaptor.ClickhouseAdaptor)
Mimic.copy(Logflare.Backends.Adaptor.ClickhouseAdaptor.ConnectionManager)
Mimic.copy(Logflare.Backends.Adaptor.SlackAdaptor.Client)
Mimic.copy(Logflare.Backends.Adaptor.WebhookAdaptor)
Mimic.copy(Logflare.Backends.Adaptor.WebhookAdaptor.Client)
Mimic.copy(Logflare.Billing)
Mimic.copy(Logflare.Cluster.Utils)
Mimic.copy(Logflare.Google.BigQuery)
Mimic.copy(Logflare.Google.BigQuery.SchemaUtils)
Mimic.copy(Logflare.Google.CloudResourceManager)
Mimic.copy(Logflare.Logs)
Mimic.copy(Logflare.Logs.LogEvents)
Mimic.copy(Logflare.Logs.SearchQueryExecutor)
Mimic.copy(Logflare.Lql)
Mimic.copy(Logflare.Mailer)
Mimic.copy(Logflare.SingleTenant)
Mimic.copy(Logflare.Sources)
Mimic.copy(Logflare.Sources.Cache)
Mimic.copy(Logflare.Sources.Source.BigQuery.Schema)
Mimic.copy(Logflare.Sources.Source.RateCounterServer)
Mimic.copy(Logflare.Sources.Source.Supervisor)
Mimic.copy(Logflare.SystemMetrics.AllLogsLogged)
Mimic.copy(Logflare.Users)
Mimic.copy(Logflare.Users.Cache)
Mimic.copy(Logflare.Utils)
Mimic.copy(LogflareWeb.Plugs.RateLimiter)
{:ok, _} = Application.ensure_all_started(:ex_machina)
{:ok, _} = Application.ensure_all_started(:mimic)

# stub all outgoing requests
Mimic.stub(Goth)
Mimic.stub(Finch)

ExUnit.configure(
  exclude: [not_implemented: true, integration: true, failing: true, benchmark: true]
)

Ecto.Adapters.SQL.Sandbox.mode(Logflare.Repo, :manual)
