test: AlertLive sort_alerts impact branch + minor sweep
This commit is contained in:
parent
1c2b9efef7
commit
7519808e92
1 changed files with 25 additions and 0 deletions
|
|
@ -80,6 +80,31 @@ defmodule ToweropsWeb.AlertLive.IndexHelpersTest do
|
|||
assert first.alert_type == "device_down"
|
||||
assert is_nil(first.resolved_at)
|
||||
end
|
||||
|
||||
test "sort by impact puts highest subscriber count first" do
|
||||
alert_a = %{
|
||||
gaiia_impact: %{"total_subscribers" => 5},
|
||||
device: %{site_id: "s1"},
|
||||
alert_type: "x",
|
||||
resolved_at: nil,
|
||||
triggered_at: ago(1)
|
||||
}
|
||||
|
||||
alert_b = %{
|
||||
gaiia_impact: %{"total_subscribers" => 100},
|
||||
device: %{site_id: "s2"},
|
||||
alert_type: "x",
|
||||
resolved_at: nil,
|
||||
triggered_at: ago(1)
|
||||
}
|
||||
|
||||
alert_c = %{gaiia_impact: nil, device: %{site_id: "s1"}, alert_type: "x", resolved_at: nil, triggered_at: ago(1)}
|
||||
|
||||
[first, second, third] = Index.sort_alerts([alert_a, alert_b, alert_c], "impact", %{})
|
||||
assert first.gaiia_impact["total_subscribers"] == 100
|
||||
assert second.gaiia_impact["total_subscribers"] == 5
|
||||
assert is_nil(third.gaiia_impact)
|
||||
end
|
||||
end
|
||||
|
||||
describe "get_site_subscriber_count/1" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue