package backup import ( "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/settings" ) // R-252 — THE PAGE'S QUESTION AND THE RESOLVER'S ANSWER ARE THE SAME QUESTION. // // The restore page renders its "re-attach your drive" notice from HasRestoreDestination(); every // restore refuses from offboxRestoreScratchDir(). If those two ever disagree the page either warns a // box that would restore fine, or stays silent on one that cannot — and the second is R-252 exactly // as the fifth walk met it. So this asserts the CONSEQUENCE (does the resolver refuse?) against the // predicate the page renders from, on one fixture. // // RED-PROOF: make HasRestoreDestination return true unconditionally and the first block fails — the // predicate claims a destination while the resolver refuses in the very next assertion. func TestHasRestoreDestination_AgreesWithTheResolver(t *testing.T) { m, sett := bareManager(t) // No registered storage path: the resolver refuses, and the predicate must say so. if m.HasRestoreDestination() { t.Error("HasRestoreDestination() is true with no registered storage path — the restore page " + "would stay silent while every restore refuses") } if _, _, err := m.offboxRestoreScratchDir("calibre-web"); err == nil { t.Fatal("the resolver found a destination with no registered storage path — fixture is wrong, " + "so the agreement below would prove nothing") } else if !strings.Contains(err.Error(), "Tárhely") { t.Errorf("the refusal names no route: %v", err) } // Re-attach a drive, exactly as the customer does from Tárhely → Meghajtók. if err := sett.AddStoragePath(settings.StoragePath{Path: "/mnt/felhom-drives/adatok", Label: "Adatok", Schedulable: true}); err != nil { t.Fatalf("register storage path: %v", err) } if !m.HasRestoreDestination() { t.Error("HasRestoreDestination() is still false after the drive was re-attached — the notice " + "would stay on screen after the customer fixed the thing it asked them to fix") } if _, _, err := m.offboxRestoreScratchDir("calibre-web"); err != nil { t.Errorf("the resolver still refuses after a drive was registered: %v", err) } }