From 7d8951435e6cce8acedba87baf7e4f7350a50395 Mon Sep 17 00:00:00 2001 From: Uku Taht <uku.taht@gmail.com> Date: Wed, 13 Jan 2021 16:15:03 +0200 Subject: [PATCH] Add test configuration --- .env.test | 5 +++++ config/runtime.exs | 2 +- config/test.exs | 32 ++++++-------------------------- mix.exs | 6 ------ 4 files changed, 12 insertions(+), 33 deletions(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 00000000..ed3c5112 --- /dev/null +++ b/.env.test @@ -0,0 +1,5 @@ +DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/plausible_test +CLICKHOUSE_DATABASE_URL=http://127.0.0.1:8123/plausible_test +CRON_ENABLED=false +LOG_LEVEL=warn +ENVIRONMENT=test diff --git a/config/runtime.exs b/config/runtime.exs index 7b8345d9..165cc991 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,6 +1,6 @@ import Config -if config_env() == :dev do +if config_env() in [:dev, :test] do Envy.auto_load() end diff --git a/config/test.exs b/config/test.exs index 9db5172a..50eeb606 100644 --- a/config/test.exs +++ b/config/test.exs @@ -2,39 +2,20 @@ import Config # We don't run a server during test. If one is required, # you can enable the server option below. -config :plausible, PlausibleWeb.Endpoint, - http: [port: 4002], - server: false +config :plausible, PlausibleWeb.Endpoint, server: false -# Print only warnings and errors during test -config :logger, level: :warn - -# Reduce bcrypt rounds to speed up test suite config :bcrypt_elixir, :log_rounds, 4 -# Configure your database -config :plausible, - Plausible.Repo, - url: - System.get_env( - "DATABASE_URL", - "postgres://postgres:postgres@127.0.0.1:5432/plausible_test" - ), - pool: Ecto.Adapters.SQL.Sandbox +config :plausible, Plausible.Repo, + pool: Ecto.Adapters.SQL.Sandbox, + url: "postgres://postgres:postgres@127.0.0.1:5432/plausible_test" config :plausible, Plausible.ClickhouseRepo, loggers: [Ecto.LogEntry], - pool_size: String.to_integer(System.get_env("CLICKHOUSE_DATABASE_POOLSIZE", "5")), - url: - System.get_env( - "CLICKHOUSE_DATABASE_URL", - "http://127.0.0.1:8123/plausible_test" - ) + pool_size: 5 config :plausible, Plausible.Mailer, adapter: Bamboo.TestAdapter -config :plausible, Oban, crontab: false, queues: false - config :plausible, paddle_api: Plausible.PaddleApi.Mock, google_api: Plausible.Google.Api.Mock @@ -56,5 +37,4 @@ config :geolix, ] config :plausible, - session_timeout: 0, - environment: System.get_env("ENVIRONMENT", "test") + session_timeout: 0 diff --git a/mix.exs b/mix.exs index 143a1497..573ddb27 100644 --- a/mix.exs +++ b/mix.exs @@ -106,12 +106,6 @@ defmodule Plausible.MixProject do ] end - # Aliases are shortcuts or tasks specific to the current project. - # For example, to create, migrate and run the seeds file at once: - # - # $ mix ecto.setup - # - # See the documentation for `Mix` for more info on aliases. defp aliases do [ "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], -- GitLab