test(agent_channel): cover assignment-disabled, missing-check, wrong-org branches
This commit is contained in:
parent
c7479292d4
commit
20413d2050
2 changed files with 37 additions and 0 deletions
|
|
@ -48,5 +48,29 @@ defmodule ToweropsWeb.HealthControllerTest do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns 503 when redis is configured but unreachable", %{conn: conn} do
|
||||||
|
previous = Application.get_env(:towerops, :redis)
|
||||||
|
# Point at a closed port on a routable but unreachable address.
|
||||||
|
# 198.51.100.0/24 is TEST-NET-2 (RFC 5737) — guaranteed not routable on the public internet.
|
||||||
|
Application.put_env(:towerops, :redis, host: "198.51.100.1", port: 1, timeout: 50)
|
||||||
|
|
||||||
|
try do
|
||||||
|
conn = get(conn, "/health")
|
||||||
|
# Expect 503 with redis disconnected
|
||||||
|
body = response(conn, 503)
|
||||||
|
result = Jason.decode!(body)
|
||||||
|
assert result["status"] == "error"
|
||||||
|
# Database is still connected in tests — exercises db_status_string(:ok)
|
||||||
|
assert result["database"] == "connected"
|
||||||
|
assert result["redis"] == "disconnected"
|
||||||
|
after
|
||||||
|
if previous do
|
||||||
|
Application.put_env(:towerops, :redis, previous)
|
||||||
|
else
|
||||||
|
Application.delete_env(:towerops, :redis)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,18 @@ defmodule ToweropsWeb.Plugs.UpdateSessionActivityTest do
|
||||||
|
|
||||||
assert conn.state == :unset
|
assert conn.state == :unset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "starts background task when user_token and live_socket_id present", %{conn: conn} do
|
||||||
|
# Exercises the get_session/2 call for :live_socket_id within call/2.
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> init_test_session(%{
|
||||||
|
user_token: "existing-token",
|
||||||
|
live_socket_id: "users_sessions:abc"
|
||||||
|
})
|
||||||
|
|> UpdateSessionActivity.call(%{})
|
||||||
|
|
||||||
|
assert conn.state == :unset
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue