mirror of
https://github.com/benbusby/farside.git
synced 2025-03-14 19:26:30 -04:00
Test for valid service redirects
Updates testing to iterate through all available services and validate that each one correctly produces a 302 redirect.
This commit is contained in:
parent
2189c9ddca
commit
f33279c41b
2
.github/workflows/elixir.yml
vendored
2
.github/workflows/elixir.yml
vendored
@ -38,4 +38,4 @@ jobs:
|
||||
run: FARSIDE_TEST=1 mix run update.exs
|
||||
|
||||
- name: Run tests
|
||||
run: mix test
|
||||
run: mix test --trace
|
||||
|
@ -1,4 +1,6 @@
|
||||
defmodule FarsideTest do
|
||||
@services_json Application.fetch_env!(:farside, :services_json)
|
||||
|
||||
use ExUnit.Case
|
||||
use Plug.Test
|
||||
|
||||
@ -15,4 +17,40 @@ defmodule FarsideTest do
|
||||
assert conn.state == :sent
|
||||
assert conn.status == 200
|
||||
end
|
||||
|
||||
test "/ping" do
|
||||
conn =
|
||||
:get
|
||||
|> conn("/ping", "")
|
||||
|> Router.call(@opts)
|
||||
|
||||
assert conn.state == :sent
|
||||
assert conn.status == 200
|
||||
assert conn.resp_body == "PONG"
|
||||
end
|
||||
|
||||
test "/:service" do
|
||||
{:ok, file} = File.read(@services_json)
|
||||
{:ok, service_list} = Poison.decode(file, as: [%{}])
|
||||
|
||||
service_names =
|
||||
Enum.map(
|
||||
service_list,
|
||||
fn service -> service["type"] end
|
||||
)
|
||||
|
||||
IO.puts("")
|
||||
|
||||
Enum.map(service_names, fn service_name ->
|
||||
IO.puts("/#{service_name}")
|
||||
|
||||
conn =
|
||||
:get
|
||||
|> conn("/#{service_name}", "")
|
||||
|> Router.call(@opts)
|
||||
|
||||
assert conn.state == :set
|
||||
assert conn.status == 302
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user