diff --git a/test/test_helper.exs b/test/test_helper.exs index 9d0245ec..27abfc49 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -47,13 +47,28 @@ ExUnit.start() # aren't installed (e.g. CI test gate runs in a lean image without # gdal-bin). Locally we install GDAL via `brew install gdal` per # CLAUDE.md, so the test runs there. -extra_excludes = +gdal_excludes = if System.find_executable("gdal_translate") && System.find_executable("gdaldem") do [] else [:requires_gdal] end +# Skip Redis-backed tests when Redis isn't reachable on localhost:6379 +# (e.g. the Forgejo CI test gate has no Redis service). Local dev runs +# Redis via direnv/services so the tests run there. +redis_excludes = + case :gen_tcp.connect(~c"127.0.0.1", 6379, [:binary, active: false], 250) do + {:ok, sock} -> + :gen_tcp.close(sock) + [] + + {:error, _} -> + [:requires_redis] + end + +extra_excludes = gdal_excludes ++ redis_excludes + # Exclude tests by default # Run specific tests with: mix test --only ExUnit.configure( diff --git a/test/towerops/redis_health_check_test.exs b/test/towerops/redis_health_check_test.exs index 82f26597..743d3d8e 100644 --- a/test/towerops/redis_health_check_test.exs +++ b/test/towerops/redis_health_check_test.exs @@ -5,6 +5,8 @@ defmodule Towerops.RedisHealthCheckTest do alias Towerops.RedisHealthCheck + @moduletag :requires_redis + describe "wait_for_redis/2" do test "returns :ok when Redis is available" do redis_config = Application.get_env(:towerops, :redis, host: "localhost", port: 6379) diff --git a/test/towerops/security/four_oh_four_tracker_test.exs b/test/towerops/security/four_oh_four_tracker_test.exs index e707cb42..07a9b36c 100644 --- a/test/towerops/security/four_oh_four_tracker_test.exs +++ b/test/towerops/security/four_oh_four_tracker_test.exs @@ -4,6 +4,7 @@ defmodule Towerops.Security.FourOhFourTrackerTest do alias Towerops.Security.FourOhFourTracker @moduletag :four_oh_four_tracker + @moduletag :requires_redis setup do # Ensure a real Redix connection exists for these tests.