package app import ( "testing" "github.com/jan/fm-rds-tx/internal/output" ) func TestRuntimeIndicatorAndAlert(t *testing.T) { cases := []struct { name string health output.QueueHealth recentLate bool wantIndicator RuntimeIndicator wantAlert string }{ { name: "queue critical", health: output.QueueHealthCritical, wantIndicator: RuntimeIndicatorQueueCritical, wantAlert: "queue health critical", }, { name: "queue low", health: output.QueueHealthLow, wantIndicator: RuntimeIndicatorDegraded, wantAlert: "queue health low", }, { name: "late buffers", health: output.QueueHealthNormal, recentLate: true, wantIndicator: RuntimeIndicatorDegraded, wantAlert: "late buffers", }, { name: "late buffers override queue low", health: output.QueueHealthLow, recentLate: true, wantIndicator: RuntimeIndicatorDegraded, wantAlert: "late buffers", }, { name: "normal", health: output.QueueHealthNormal, wantIndicator: RuntimeIndicatorNormal, wantAlert: "", }, } for _, tc := range cases { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() got := runtimeIndicator(tc.health, tc.recentLate) if got != tc.wantIndicator { t.Fatalf("indicator: expected %s, got %s", tc.wantIndicator, got) } alert := runtimeAlert(tc.health, tc.recentLate) if alert != tc.wantAlert { t.Fatalf("alert: expected %q, got %q", tc.wantAlert, alert) } }) } }