Files
felhom-controller/controller/internal/stacks/r669_restore_meta_test.go
T
2026-09-24 16:49:43 +02:00

34 lines
1.4 KiB
Go

package stacks
import (
"os"
"path/filepath"
"strings"
"testing"
)
// R-669 (v0.270.0): after a restore writes the app's .felhom.yml, that file IS the pinned version's
// record — so the NEXT update's undo judges the old version with the restored probe, not the failed
// step's. Asserted on what the undo actually reads: savePreUpdateMeta's copy.
//
// COMPANION RED-PROOF (REPORT.md): make RecordRestoredAppliedMeta a no-op (v0.269.1: no restore path
// rewrote applied-meta) → "the next undo would judge with the failed step's probe".
func TestR669_RestoreResetsTheAppliedRecord(t *testing.T) {
m, _, _, _ := newSlice4Manager(t)
dir := filepath.Dir(m.stacks["nextcloud"].ComposePath)
if err := os.MkdirAll(filepath.Dir(AppliedMetaFile(dir)), 0o755); err != nil {
t.Fatal(err)
}
mustWrite(t, AppliedMetaFile(dir), "healthcheck:\n checks:\n - type: api\n port: 8999\n") // left by the failed step
mustWrite(t, filepath.Join(dir, ".felhom.yml"), "healthcheck:\n checks:\n - type: api\n port: 80\n") // written by the restore
m.RecordRestoredAppliedMeta("nextcloud", dir)
md, err := savePreUpdateMeta(dir)
if err != nil {
t.Fatal(err)
}
b, _ := os.ReadFile(filepath.Join(md, ".felhom.yml"))
if strings.Contains(string(b), "8999") || !strings.Contains(string(b), "port: 80") {
t.Fatalf("the next undo would judge with the failed step's probe:\n%s", b)
}
}