autonomy notify: enforce notify allowlist from config and add guard test

This commit is contained in:
DBT
2026-02-28 13:01:54 +00:00
parent 19e7e550ca
commit 6705a2b4e8
5 changed files with 41 additions and 3 deletions

View File

@@ -0,0 +1,21 @@
package autonomy
import "testing"
func TestShouldNotify_RespectsNotifyAllowChats(t *testing.T) {
e := &Engine{opts: Options{
DefaultNotifyChannel: "telegram",
DefaultNotifyChatID: "chat-1",
NotifyAllowChats: []string{"chat-2", "chat-3"},
NotifyCooldownSec: 1,
NotifySameReasonCooldownSec: 1,
}}
if e.shouldNotify("k1", "") {
t.Fatalf("expected notify to be blocked when chat not in allowlist")
}
e.opts.NotifyAllowChats = []string{"chat-1"}
if !e.shouldNotify("k2", "") {
t.Fatalf("expected notify to pass when chat in allowlist")
}
}