Notify on failed runs and with ntfy disabled

This commit is contained in:
2026-11-12 01:55:28 +00:00
parent 2330f50268
commit 7b1b91f452
10 changed files with 78 additions and 37 deletions
@@ -78,9 +78,8 @@ func TestNotificationSettingsRejectUnknownOrInvalid(t *testing.T) {
}
}
// A run's end (succeeded or failed) enqueues its generic alert only for a run
// marked "on", or for "auto" when run_finished (default off) opts into every
// run end. Waiting notifies auto and on runs regardless; "off" never notifies.
// Failed runs always enqueue their generic alert (unless off). Successful runs
// require "on" or run_finished. Waiting notifies auto and on runs regardless.
func TestRunEndEnqueueFollowsNotifyModeAndRunFinished(t *testing.T) {
for _, status := range []string{"succeeded", "failed", "waiting"} {
for _, tc := range []struct {
@@ -91,6 +90,9 @@ func TestRunEndEnqueueFollowsNotifyModeAndRunFinished(t *testing.T) {
{"auto", false, 0}, {"auto", true, 1}, {"on", false, 1}, {"on", true, 1}, {"off", false, 0}, {"off", true, 0},
} {
want := tc.want
if status == "failed" && tc.mode == "auto" {
want = 1
}
if status == "waiting" && tc.mode == "auto" {
want = 1
}
@@ -138,7 +140,7 @@ func TestLegacyRunFinishedValueIsIgnored(t *testing.T) {
if err := notificationTransition(ctx, s, id, "failed"); err != nil {
t.Fatal(err)
}
if got, err := s.RunNotifications(ctx, id); err != nil || len(got) != 0 {
if got, err := s.RunNotifications(ctx, id); err != nil || len(got) != 1 {
t.Fatalf("notifications = %+v, %v", got, err)
}
}