Files
felhom-controller/controller/internal/settings/r1340_why_test.go
T

42 lines
2.0 KiB
Go

package settings
import (
"strings"
"testing"
)
// R-1340, second producer (found live 2026-10-29 on Tester 1): the hold's Why() — the hub's „Held apps" line and the
// box's app_held event — still said „held after an off-site restore failed its database replay" for a LOCAL restore of
// an app with no database whose put-back stop failed. It must name what the hold record carries.
// RED-PROOF: seen failing on the old fixed sentence.
func TestR1340_WhyNamesTheMixedCause(t *testing.T) {
for _, tc := range []struct {
name string
h RestoreHold
want, not []string
}{
{"local put-back, no database", RestoreHold{Reason: HoldReasonRestoreMixed, At: "T", RestoreKind: RestoreKindLocal, MixedCause: MixedCausePutBack, FailedStep: "stopping the app before the put-back"},
[]string{"local restore", "putting the live data back failed", "stopping the app before the put-back"}, []string{"database", "off-site"}},
{"off-site database replay", RestoreHold{Reason: HoldReasonRestoreMixed, At: "T", RestoreKind: RestoreKindOffsite, MixedCause: MixedCausePutBack, DBReplay: true},
[]string{"off-site restore", "database replay", "putting the live data back failed"}, nil},
{"definition write", RestoreHold{Reason: HoldReasonRestoreMixed, At: "T", RestoreKind: RestoreKindOffsite, MixedCause: MixedCauseDefinitionWrite},
[]string{"definition"}, []string{"database"}},
{"interrupted put-back", RestoreHold{Reason: HoldReasonRestoreMixed, At: "T", MixedCause: MixedCauseInterruptedPutBack},
[]string{"interrupted"}, []string{"database"}},
{"legacy record", RestoreHold{Reason: HoldReasonRestoreMixed, At: "T"},
[]string{"stopped half-way", "clear the hold"}, []string{"database", "off-site"}},
} {
got := tc.h.Why()
for _, w := range tc.want {
if !strings.Contains(got, w) {
t.Errorf("%s: %q lacks %q", tc.name, got, w)
}
}
for _, n := range tc.not {
if strings.Contains(got, n) {
t.Errorf("%s: %q says %q", tc.name, got, n)
}
}
}
}