fix: isolate precommit steps with cmd, split test alias from DB setup
- Move ecto.create/ecto.migrate from test alias to test.setup - Use cmd MIX_ENV=test in precommit to isolate each step in a fresh process - Move Mox.defmock from test_helper.exs to valkey_test.exs
This commit is contained in:
parent
255c99cb36
commit
b1b9ff63e8
2 changed files with 14 additions and 4 deletions
10
mix.exs
10
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue