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