package web import ( "context" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/agentapi" "gitea.dooplex.hu/admin/felhom-controller/internal/util" ) // R-1069: a disk the agent cannot bind a format to (a virtio disk without a serial) is refused with a plain // sentence in the household's language — what happened, that nothing changed, who can fix it — and the init stops // before any mount or registration. The agent's refusal itself is unchanged (a safety rule). // RED-PROOF: with the ErrNoDurableID branch removed from runStorageInit, the error is „formázás sikertelen: // agentapi: format refused — …" and the HU/EN assertions fail. func TestR1069_NoDurableIDIsAPlainRefusal(t *testing.T) { s := testServer(t) agent := &mockAgent{formatErr: agentapi.ErrNoDurableID} _, err := s.runStorageInit(context.Background(), agent, "/dev/vdb", "ext4", "/mnt/felhom-drives/adat", "Adat", false, false, "", nil) if err == nil { t.Fatal("the init went on although the agent refused the format") } if len(agent.assignCalls) != 0 { t.Fatalf("a mount was attempted after the refusal: %v", agent.assignCalls) } hu, en := util.ErrText("hu", err), util.ErrText("en", err) for _, frag := range []string{"virtu", "sorozatsz", "nem v", "zemeltet"} { if !strings.Contains(hu, frag) { t.Errorf("HU text lacks %q: %q", frag, hu) } } for _, frag := range []string{"virtual machine", "serial number", "was not changed", "operator"} { if !strings.Contains(en, frag) { t.Errorf("EN text lacks %q: %q", frag, en) } } if strings.Contains(hu, "agentapi") || strings.Contains(en, "agentapi") { t.Errorf("the raw agent text reached the household: %q / %q", hu, en) } }