R-1270 (P2): a restore whose app does not reach running in time is never a success — every restore path returns ErrRestoreNotStarted, the household reads that the data is back but the app has not started yet, one operator alarm; the data stays, the undo copy is kept, a late start turns the record into a success and releases the copy. Red-proved. Commit only.
gates / gates (push) Successful in 1m32s
gates / gates (push) Successful in 1m32s
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/config"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/util"
|
||||
)
|
||||
|
||||
// R-1270 — a restore whose data is back but whose app did not start is recorded as NOT ok, with its own sentence
|
||||
// alone (never „Visszaállítás sikertelen: …", never „…az alkalmazás újraindult."); any other error stays a failure.
|
||||
// COMPANION RED-PROOF (REPORT.md): drop the errors.Is branch in endRestoreFailed → this fails on the „sikertelen" prefix
|
||||
// and on NotStarted.
|
||||
func TestR1270_TheRecordOfANotStartedRestore(t *testing.T) {
|
||||
lg := log.New(io.Discard, "", 0)
|
||||
cfg := &config.Config{}
|
||||
cfg.Paths.DataDir = t.TempDir()
|
||||
s := &Server{cfg: cfg, backupMgr: backup.NewManager(cfg, nil, lg), logger: lg}
|
||||
|
||||
s.backupMgr.BeginRestoreOp("restore", "tandoor")
|
||||
s.endRestoreFailed("note.restore.unit_failed", util.MsgErrorf(backup.ErrRestoreNotStarted, "err.backup.restore_not_started", "tandoor"), "")
|
||||
st := s.backupMgr.RestoreStatus()
|
||||
if st.Last == nil || st.Last.OK || !st.Last.NotStarted {
|
||||
t.Fatalf("a not-started restore is recorded not ok and not started: %+v", st.Last)
|
||||
}
|
||||
if strings.Contains(st.Last.Message, "sikertelen") || strings.Contains(st.Last.Message, "újraindult") || !strings.Contains(st.Last.Message, "még nem indult el") {
|
||||
t.Fatalf("the household reads the not-started sentence alone: %q", st.Last.Message)
|
||||
}
|
||||
|
||||
s.backupMgr.BeginRestoreOp("restore", "tandoor")
|
||||
s.endRestoreFailed("note.restore.unit_failed", errors.New("boom"), "")
|
||||
if st := s.backupMgr.RestoreStatus(); st.Last.OK || st.Last.NotStarted || !strings.Contains(st.Last.Message, "sikertelen") {
|
||||
t.Fatalf("any other error stays a failure: %+v", st.Last)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user