Notify on failed runs and with ntfy disabled
This commit is contained in:
@@ -278,7 +278,7 @@ func TestRunAttentionEventMapping(t *testing.T) {
|
||||
{"running", ""},
|
||||
{"succeeded", ""},
|
||||
{"canceled", ""},
|
||||
{"interrupted", ""},
|
||||
{"interrupted", "interrupted"},
|
||||
{"", ""},
|
||||
} {
|
||||
if got := runAttentionEvent(test.status); got != test.want {
|
||||
@@ -320,7 +320,7 @@ func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A run that needs nobody publishes nothing.
|
||||
for _, status := range []string{"queued", "running", "succeeded", "canceled", "interrupted"} {
|
||||
for _, status := range []string{"queued", "running", "succeeded", "canceled"} {
|
||||
r.notifyRun(7, "release", status, 1, "build", "")
|
||||
}
|
||||
select {
|
||||
@@ -332,7 +332,7 @@ func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
r.notifyRun(7, "release", protocol.RunStatusWaiting, 1, "approve", "")
|
||||
// A run that stays waiting is never republished, on a later call or a re-request.
|
||||
r.notifyRun(7, "release", protocol.RunStatusWaiting, 1, "approve", "")
|
||||
// An auto run's failure is silent: only runs marked "on" announce their end.
|
||||
// An auto run's failure announces its end.
|
||||
r.notifyRun(8, "release", "failed", 2, "deploy", "provider returned 500")
|
||||
// A failed run marked "on" publishes once, with its diagnostic.
|
||||
r.setNotifyMode(7, "on")
|
||||
@@ -352,12 +352,16 @@ func TestRunAttentionNotificationDelivery(t *testing.T) {
|
||||
t.Fatalf("notification leaked an authorization header: %q", first.authorization)
|
||||
}
|
||||
second := <-deliveries
|
||||
if second.title != "Run failed" || !strings.Contains(second.message, "Run #7") || !strings.Contains(second.message, "release") || !strings.Contains(second.message, "deploy") || !strings.Contains(second.message, "provider returned 500") {
|
||||
if second.title != "Run failed" || !strings.Contains(second.message, "Run #8") {
|
||||
t.Fatalf("failed notification is not actionable: %+v", second)
|
||||
}
|
||||
if second.click != "pipelines://run/7" || second.actions != "view, Open in browser, https://pipelines.example.com/runs/7" {
|
||||
if second.click != "pipelines://run/8" || second.actions != "view, Open in browser, https://pipelines.example.com/runs/8" {
|
||||
t.Fatalf("failed notification click does not open the run: %q", second.click)
|
||||
}
|
||||
third := <-deliveries
|
||||
if third.title != "Run failed" || !strings.Contains(third.message, "Run #7") {
|
||||
t.Fatalf("marked failed notification is not actionable: %+v", third)
|
||||
}
|
||||
select {
|
||||
case got := <-deliveries:
|
||||
t.Fatalf("third notification delivered for two genuine events: %+v", got)
|
||||
|
||||
Reference in New Issue
Block a user