Files
felhom-controller/controller/internal/backup/r721_volume_dump_stop_test.go
T
2026-09-30 10:31:55 +02:00

41 lines
1.5 KiB
Go

package backup
import "testing"
// stopDuringDump is the real DumpAppVolumesSafe's provider: the household presses Stop while the dump holds
// the app down (between StopStack and the restart).
type stopDuringDump struct {
suppressWatchProvider
wantsStopped bool
started int
}
func (p *stopDuringDump) StopStack(n string) error {
p.wantsStopped = true // the household's Stop lands during the dump
return p.suppressWatchProvider.StopStack(n)
}
func (p *stopDuringDump) StartStack(n string) error {
p.started++
return p.suppressWatchProvider.StartStack(n)
}
func (p *stopDuringDump) WantsStopped(string) bool { return p.wantsStopped }
// R-721 (v0.283.0): the nightly volume dump does not start an app the household stopped while it was down.
// COMPANION RED-PROOF: remove the WantsStopped check in DumpAppVolumesSafe → started=1.
func TestR721_VolumeDumpKeepsTheHouseholdsStop(t *testing.T) {
p := &stopDuringDump{}
m := newSuppressManager(t, &p.suppressWatchProvider)
m.stackProvider = p
if err := m.DumpAppVolumesSafe("actualbudget"); err != nil {
t.Fatalf("DumpAppVolumesSafe: %v", err)
}
if p.started != 0 {
t.Fatalf("the dump started the app %d time(s) after the household stopped it (R-721)", p.started)
}
// The crash marker is what a restart after a controller crash reads: it must owe nothing. (The short
// alarm-grace set is a different thing and stays by design.)
if got := m.appStop.HeldStacks(); len(got) != 0 {
t.Fatalf("the stop marker still holds %v — the next startup would restart an app the household stopped", got)
}
}