From 587e81bdad9c13fedc19615ccdc2279b143a3c26 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 9 May 2026 12:22:35 -0500 Subject: [PATCH] test: Gaiia.Actions API failure paths cover Logger.warning branches --- test/towerops/gaiia/actions_test.exs | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/towerops/gaiia/actions_test.exs b/test/towerops/gaiia/actions_test.exs index 54298d5a..9d5a6b6c 100644 --- a/test/towerops/gaiia/actions_test.exs +++ b/test/towerops/gaiia/actions_test.exs @@ -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