Skip to content

Commit

Permalink
Setup test case and bypass for uplink nodes listing
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jan 9, 2025
1 parent fef4c5b commit f473489
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Empty file.
36 changes: 36 additions & 0 deletions test/uplink/availability_test.exs
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
defmodule Uplink.AvailabilityTest do
use ExUnit.Case

alias Uplink.Availability

setup do
bypass = Bypass.open()

Cache.put(:self, %{
"credential" => %{
"endpoint" => "http://localhost:#{bypass.port}"
}
})

response = File.read!("test/fixtures/lxd/cluster/members/list.json")

Cache.delete(:cluster_members)

{:ok, bypass: bypass}
end

describe "check availability of the nodes in the cluster" do
test "return availability check result", %{
bypass: bypass,
response: response
} do
Bypass.expect_once(bypass, "GET", "/1.0/cluster/members", fn conn ->
assert %{"recursion" => "1"} = conn.query_params

conn
|> Plug.Conn.put_resp_header("content-type", "application/json")
|> Plug.Conn.resp(200, response)
end)

assert {:ok, result} = Availability.check!()
end
end
end

0 comments on commit f473489

Please sign in to comment.