test: Gaiia.Actions API failure paths cover Logger.warning branches
This commit is contained in:
parent
3aed78282d
commit
587e81bdad
1 changed files with 42 additions and 0 deletions
|
|
@ -124,4 +124,46 @@ defmodule Towerops.Gaiia.ActionsTest do
|
|||
Actions.update_inventory_item(org_id, "gaiia-inv-1", %{ip_address: "10.0.0.5"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "Gaiia API failure paths (Logger.warning branches)" do
|
||||
test "create_ticket_for_alert returns error and logs warning when API fails", %{org: org} do
|
||||
device = device_fixture(%{organization_id: org.id, name: "Bad Tower"})
|
||||
|
||||
alert = %{
|
||||
id: Ecto.UUID.generate(),
|
||||
device: device,
|
||||
alert_type: "device_down",
|
||||
message: "Down",
|
||||
triggered_at: DateTime.utc_now()
|
||||
}
|
||||
|
||||
Req.Test.stub(Client, fn conn ->
|
||||
Req.Test.transport_error(conn, :econnrefused)
|
||||
end)
|
||||
|
||||
assert {:error, _reason} = Actions.create_ticket_for_alert(org.id, alert)
|
||||
end
|
||||
|
||||
test "create_subscriber_note returns error when API fails", %{org: org} do
|
||||
Req.Test.stub(Client, fn conn ->
|
||||
Req.Test.transport_error(conn, :econnrefused)
|
||||
end)
|
||||
|
||||
assert {:error, _reason} = Actions.create_subscriber_note(org.id, "acct-x", "note")
|
||||
end
|
||||
|
||||
test "update_inventory_item returns error when API fails", %{org: org} do
|
||||
Req.Test.stub(Client, fn conn ->
|
||||
Req.Test.transport_error(conn, :econnrefused)
|
||||
end)
|
||||
|
||||
assert {:error, _reason} =
|
||||
Actions.update_inventory_item(org.id, "inv-x", %{
|
||||
ip_address: "1.2.3.4",
|
||||
serial_number: "SN1",
|
||||
mac_address: "aa:bb:cc:dd:ee:ff",
|
||||
custom_field: "x"
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue