diff --git a/mix.exs b/mix.exs index 18c7971b..6ec9baac 100644 --- a/mix.exs +++ b/mix.exs @@ -150,7 +150,8 @@ defmodule Microwaveprop.MixProject do "deps.get": ["deps.get", &apply_dep_patches/1], "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], "ecto.reset": ["ecto.drop", "ecto.setup"], - test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"], + "test.setup": ["ecto.create --quiet", "ecto.migrate --quiet"], + test: ["test"], "assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"], "assets.build": [ "compile", @@ -164,7 +165,12 @@ defmodule Microwaveprop.MixProject do ©_leaflet_images/1, "phx.digest" ], - precommit: ["compile", "deps.unlock --check-unused", "format", "credo --strict", "test"] + precommit: [ + "format --check-formatted", + "cmd MIX_ENV=test mix test", + "deps.unlock --check-unused", + "cmd MIX_ENV=test mix credo --strict" + ] ] end diff --git a/test/microwaveprop/valkey_test.exs b/test/microwaveprop/valkey_test.exs index 97b4b4e4..01eec717 100644 --- a/test/microwaveprop/valkey_test.exs +++ b/test/microwaveprop/valkey_test.exs @@ -8,12 +8,16 @@ defmodule Microwaveprop.ValkeyTest do import Mox + # Defined here (not in test_helper.exs) so test_helper can load even + # when the precommit chain has purged Mox from the code path. alias Microwaveprop.Valkey - # Register Mox mock as the adapter and fake a Redix connection so - # configured?() returns true, letting command/pipeline run through the mock. alias Microwaveprop.Valkey.Conn alias Microwaveprop.Valkey.MockAdapter + Mox.defmock(MockAdapter, for: Microwaveprop.Valkey.Adapter) + + # Register Mox mock as the adapter and fake a Redix connection so + # configured?() returns true, letting command/pipeline run through the mock. setup do prev_url = Application.get_env(:microwaveprop, :valkey_url) prev_adapter = Application.get_env(:microwaveprop, :valkey_adapter)