fix: resolve test suite warnings-as-errors failures
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:
Graham McIntire 2026-08-05 08:15:58 -05:00
parent c61e27a7c8
commit 4533acd41d
3 changed files with 25 additions and 8 deletions

View file

@ -17,6 +17,7 @@ defmodule Microwaveprop.MixProject do
compilers: [:phoenix_live_view] ++ Mix.compilers(), compilers: [:phoenix_live_view] ++ Mix.compilers(),
listeners: [Phoenix.CodeReloader], listeners: [Phoenix.CodeReloader],
test_coverage: [summary: [threshold: 85]], test_coverage: [summary: [threshold: 85]],
test_ignore_filters: [~r"test/support/"],
# Disable protocol consolidation in test so test-only deps # Disable protocol consolidation in test so test-only deps
# (lazy_html) that implement core protocols (Enumerable) are # (lazy_html) that implement core protocols (Enumerable) are
# dispatched at runtime instead of failing at compile-time # dispatched at runtime instead of failing at compile-time

View file

@ -153,12 +153,20 @@ defmodule Microwaveprop.Weather.HrdpsClientTest do
describe "cycle_available?/1 (injected http_head)" do describe "cycle_available?/1 (injected http_head)" do
setup 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 -> on_exit(fn ->
if prev, if prev_head,
do: Application.put_env(:microwaveprop, :hrdps_http_head, prev), do: Application.put_env(:microwaveprop, :hrdps_http_head, prev_head),
else: Application.delete_env(:microwaveprop, :hrdps_http_head) else: Application.delete_env(:microwaveprop, :hrdps_http_head)
if prev_fn,
do: Application.put_env(:microwaveprop, :hrdps_cycle_available_fn, prev_fn)
end) end)
:ok :ok

View file

@ -11,11 +11,19 @@ end
# starts lazily compiling the test suite. The parallel compiler workers # starts lazily compiling the test suite. The parallel compiler workers
# inherit the code server state, so loading them here makes them visible # inherit the code server state, so loading them here makes them visible
# everywhere. # everywhere.
Code.require_file("test/support/data_case.ex") # Use ensure_loaded!/1 (not require_file) because mix compile already
Code.require_file("test/support/conn_case.ex") # compiles these into _build — require_file recompiles them redundantly
Code.require_file("test/support/fixtures/accounts_fixtures.ex") # and triggers "redefining module" warnings that fail --warnings-as-errors.
Code.require_file("test/support/fixtures/beacons_fixtures.ex") Enum.each(
Code.require_file("test/support/fixtures/contacts_fixtures.ex") [
Microwaveprop.DataCase,
MicrowavepropWeb.ConnCase,
Microwaveprop.AccountsFixtures,
Microwaveprop.BeaconsFixtures,
Microwaveprop.ContactsFixtures
],
&Code.ensure_loaded!/1
)
ExUnit.start() ExUnit.start()