package web import ( "context" "os" "strings" "testing" ) // R-675: when a unit restore is refused for a file app, the sentence must name the route that brings // the files back. Since decision 26 (v0.269.0) a second drive holding a WHOLE copy has its own action // („Teljes visszaállítás a másolatból") — but the refusal still sent the household to the file-only // „Fájlok visszaállítása". The consequence asserted: for each real state the household reads the right // button name, in both languages; the whole copy wins over the file-only copy, and off-site still wins. func TestR675_RefusalNamesTheWholeCopy(t *testing.T) { s := noteServer(t) cases := []struct { name string offsite, whole, files bool huWant, enWant string huNot string }{ {"whole copy on the second drive", false, true, true, "Teljes visszaállítás a másolatból", "Full restore from the copy", "Fájlok visszaállítása"}, {"file copy only on the second drive", false, false, true, "Fájlok visszaállítása", "Restore files", "Teljes visszaállítás a másolatból"}, {"off-site copy", true, true, true, "Teljes visszaállítás (fájlok + adatbázis)", "Full restore (files + database)", "Fájlok visszaállítása"}, {"nothing", false, false, false, "nincs másolat", "There is no copy", "Fájlok visszaállítása"}, } for _, c := range cases { key := missingFileLegsRouteKey(c.offsite, c.whole, c.files) hu := s.msgLang("hu", "restore.refuse.files.head") + s.msgLang("hu", key) en := s.msgLang("en", "restore.refuse.files.head") + s.msgLang("en", key) if !strings.Contains(hu, c.huWant) || strings.Contains(hu, c.huNot) { t.Errorf("R-675 %s: the Hungarian refusal reads %q; want it to name %q and not %q", c.name, hu, c.huWant, c.huNot) } if !strings.Contains(en, c.enWant) { t.Errorf("R-675 %s: the English refusal reads %q; want it to name %q", c.name, en, c.enWant) } } // With no backup manager at all, the function answers the honest "no copy" sentence. if got := s.missingFileLegsRefusal(context.Background(), "en", "nextcloud"); !strings.Contains(got, "There is no copy") { t.Errorf("no backup manager: got %q", got) } // Wiring: the refusal consults the decision-26 whole-copy predicate. src, err := os.ReadFile("handlers.go") if err != nil { t.Fatal(err) } if !strings.Contains(string(src), "s.backupMgr.WholeOnTier(stackName, backup.UpdateTierSecondDrive)") { t.Errorf("R-675: missingFileLegsRefusal does not ask whether the second drive holds a whole copy") } }