fix: resolve test suite warnings-as-errors failures
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 7m52s
Some checks failed
Build and Push / Build and Push Docker Image (push) Failing after 7m52s
- conn_case: remove compile-time alias for AccountsFixtures to fix compilation ordering warning - hrdps_client_test: clear global hrdps_cycle_available_fn in test setup so injected http_head takes effect (2 previously failing tests) - test_helper: use Code.ensure_loaded!/1 instead of Code.require_file to avoid redefining module warnings - mix.exs: add test_ignore_filters to suppress Elixir 1.20 test support file warnings
This commit is contained in:
parent
c61e27a7c8
commit
4533acd41d
3 changed files with 25 additions and 8 deletions
1
mix.exs
1
mix.exs
|
|
@ -17,6 +17,7 @@ defmodule Microwaveprop.MixProject do
|
|||
compilers: [:phoenix_live_view] ++ Mix.compilers(),
|
||||
listeners: [Phoenix.CodeReloader],
|
||||
test_coverage: [summary: [threshold: 85]],
|
||||
test_ignore_filters: [~r"test/support/"],
|
||||
# Disable protocol consolidation in test so test-only deps
|
||||
# (lazy_html) that implement core protocols (Enumerable) are
|
||||
# dispatched at runtime instead of failing at compile-time
|
||||
|
|
|
|||
|
|
@ -153,12 +153,20 @@ defmodule Microwaveprop.Weather.HrdpsClientTest do
|
|||
|
||||
describe "cycle_available?/1 (injected http_head)" do
|
||||
setup do
|
||||
prev = Application.get_env(:microwaveprop, :hrdps_http_head)
|
||||
prev_head = Application.get_env(:microwaveprop, :hrdps_http_head)
|
||||
prev_fn = Application.get_env(:microwaveprop, :hrdps_cycle_available_fn)
|
||||
|
||||
# Clear the global cycle_available_fn so cycle_available?/1 falls
|
||||
# through to probe_cycle/1, which reads the injected http_head.
|
||||
Application.delete_env(:microwaveprop, :hrdps_cycle_available_fn)
|
||||
|
||||
on_exit(fn ->
|
||||
if prev,
|
||||
do: Application.put_env(:microwaveprop, :hrdps_http_head, prev),
|
||||
if prev_head,
|
||||
do: Application.put_env(:microwaveprop, :hrdps_http_head, prev_head),
|
||||
else: Application.delete_env(:microwaveprop, :hrdps_http_head)
|
||||
|
||||
if prev_fn,
|
||||
do: Application.put_env(:microwaveprop, :hrdps_cycle_available_fn, prev_fn)
|
||||
end)
|
||||
|
||||
:ok
|
||||
|
|
|
|||
|
|
@ -11,11 +11,19 @@ end
|
|||
# starts lazily compiling the test suite. The parallel compiler workers
|
||||
# inherit the code server state, so loading them here makes them visible
|
||||
# everywhere.
|
||||
Code.require_file("test/support/data_case.ex")
|
||||
Code.require_file("test/support/conn_case.ex")
|
||||
Code.require_file("test/support/fixtures/accounts_fixtures.ex")
|
||||
Code.require_file("test/support/fixtures/beacons_fixtures.ex")
|
||||
Code.require_file("test/support/fixtures/contacts_fixtures.ex")
|
||||
# Use ensure_loaded!/1 (not require_file) because mix compile already
|
||||
# compiles these into _build — require_file recompiles them redundantly
|
||||
# and triggers "redefining module" warnings that fail --warnings-as-errors.
|
||||
Enum.each(
|
||||
[
|
||||
Microwaveprop.DataCase,
|
||||
MicrowavepropWeb.ConnCase,
|
||||
Microwaveprop.AccountsFixtures,
|
||||
Microwaveprop.BeaconsFixtures,
|
||||
Microwaveprop.ContactsFixtures
|
||||
],
|
||||
&Code.ensure_loaded!/1
|
||||
)
|
||||
|
||||
ExUnit.start()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue