aboutsummaryrefslogtreecommitdiffstats
path: root/internal/notify/policy_test.go
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-19 09:15:53 +0200
committerDanilo M. <danix@danix.xyz>2026-10-19 09:15:53 +0200
commit1e70e552db6790f2fd07fdd1721bf6cf76e0c6b3 (patch)
tree29175225bf2297b07ef9652790978dcb337604b3 /internal/notify/policy_test.go
parent75acc11af55b4efe0ea095a52a3916b13639c2cd (diff)
downloadnotifyd-1e70e552db6790f2fd07fdd1721bf6cf76e0c6b3.tar.gz
notifyd-1e70e552db6790f2fd07fdd1721bf6cf76e0c6b3.zip
feat(notify): take the per-urgency default timeout from config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'internal/notify/policy_test.go')
-rw-r--r--internal/notify/policy_test.go19
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)
}
})