diff options
Diffstat (limited to 'internal/notify/policy_test.go')
| -rw-r--r-- | internal/notify/policy_test.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/internal/notify/policy_test.go b/internal/notify/policy_test.go index 378c573..a6ca5a5 100644 --- a/internal/notify/policy_test.go +++ b/internal/notify/policy_test.go @@ -40,22 +40,27 @@ func TestUrgencyFromHints(t *testing.T) { } func TestEffectiveTimeoutMS(t *testing.T) { + def := DefaultConfig().Timeouts + custom := Timeouts{Low: 3, Normal: 7, Critical: 60} cases := []struct { name string expire int32 u Urgency + t Timeouts want int64 }{ - {"minus one uses low default", -1, Low, 10_000}, - {"minus one uses normal default", -1, Normal, 10_000}, - {"minus one critical never", -1, Critical, 0}, - {"zero never", 0, Normal, 0}, - {"explicit wins", 3_000, Normal, 3_000}, - {"sub second exact", 1, Normal, 1}, + {"minus one uses low default", -1, Low, def, 10_000}, + {"minus one uses normal default", -1, Normal, def, 10_000}, + {"minus one critical never", -1, Critical, def, 0}, + {"minus one uses configured low", -1, Low, custom, 3_000}, + {"minus one uses configured critical", -1, Critical, custom, 60_000}, + {"zero never", 0, Normal, custom, 0}, + {"explicit wins", 3_000, Normal, custom, 3_000}, + {"sub second exact", 1, Normal, def, 1}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { - if got := EffectiveTimeoutMS(c.expire, c.u); got != c.want { + if got := EffectiveTimeoutMS(c.expire, c.u, c.t); got != c.want { t.Errorf("EffectiveTimeoutMS(%d, %q) = %d, want %d", c.expire, c.u, got, c.want) } }) |
