test: Airfiber detect_version + OnCall.Escalation start_escalation no-policy branches
This commit is contained in:
parent
1b35177c1b
commit
749fc27a80
2 changed files with 45 additions and 0 deletions
|
|
@ -72,6 +72,31 @@ defmodule Towerops.OnCall.EscalationTest do
|
|||
|
||||
assert {:error, :no_policy} = Escalation.start_escalation(alert, nil)
|
||||
end
|
||||
|
||||
test "returns :no_policy when policy_id is empty string", ctx do
|
||||
{:ok, alert} =
|
||||
Alerts.create_alert(%{
|
||||
alert_type: "device_down",
|
||||
device_id: ctx.device.id,
|
||||
triggered_at: DateTime.utc_now(),
|
||||
message: "Device is down"
|
||||
})
|
||||
|
||||
assert {:error, :no_policy} = Escalation.start_escalation(alert, "")
|
||||
end
|
||||
|
||||
test "returns :no_policy when policy id refers to a non-existent record", ctx do
|
||||
{:ok, alert} =
|
||||
Alerts.create_alert(%{
|
||||
alert_type: "device_down",
|
||||
device_id: ctx.device.id,
|
||||
triggered_at: DateTime.utc_now(),
|
||||
message: "Device is down"
|
||||
})
|
||||
|
||||
assert {:error, :no_policy} =
|
||||
Escalation.start_escalation(alert, Ecto.UUID.generate())
|
||||
end
|
||||
end
|
||||
|
||||
describe "acknowledge_incident/2" do
|
||||
|
|
|
|||
|
|
@ -170,4 +170,24 @@ defmodule Towerops.Snmp.Profiles.Vendors.AirfiberTest do
|
|||
assert sensors == []
|
||||
end
|
||||
end
|
||||
|
||||
describe "detect_version/1" do
|
||||
test "returns the version string when SNMP responds" do
|
||||
expect(SnmpMock, :get, fn _, "1.3.6.1.4.1.41112.1.3.2.1.40.1", _opts ->
|
||||
{:ok, "v4.1.0"}
|
||||
end)
|
||||
|
||||
assert "v4.1.0" == Airfiber.detect_version(@client_opts)
|
||||
end
|
||||
|
||||
test "returns nil when SNMP returns an empty string" do
|
||||
expect(SnmpMock, :get, fn _, _, _ -> {:ok, ""} end)
|
||||
assert nil == Airfiber.detect_version(@client_opts)
|
||||
end
|
||||
|
||||
test "returns nil on timeout" do
|
||||
expect(SnmpMock, :get, fn _, _, _ -> {:error, :timeout} end)
|
||||
assert nil == Airfiber.detect_version(@client_opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue