Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Add test configuration

Uku Taht7d8951435e6c
diff --git a/.env.test b/.env.test
new file mode 100644
index 0000000000..ed3c511213
--- /dev/null
+++ b/.env.test
@@ -0,0 +1,5 @@
+DATABASE_URL=postgres://postgres:[email protected]: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 7b8345d914..165cc9914d 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 9db5172ae4..50eeb6061c 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:[email protected]:5432/plausible_test"
- ),
- pool: Ecto.Adapters.SQL.Sandbox
+config :plausible, Plausible.Repo,
+ pool: Ecto.Adapters.SQL.Sandbox,
+ url: "postgres://postgres:[email protected]: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 143a1497da..573ddb27a3 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"],