From 1e70e552db6790f2fd07fdd1721bf6cf76e0c6b3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 19 Oct 2026 09:15:53 +0200 Subject: feat(notify): take the per-urgency default timeout from config Co-Authored-By: Claude Opus 5.5 --- internal/notify/policy_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'internal/notify/policy_test.go') 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) } }) -- cgit v1.2.3