package osupdate import ( "os" "path/filepath" "testing" "gitea.dooplex.hu/admin/felhom-agent/internal/hub" ) // After a boot the agent has not fetched the hub's block yet; the after-boot kernel report must still carry the // box's real ring (seen 2026-10-08: a ring-0 box's „judging" report said ring 1). Red-proof: return Block().Ring // from kernelReportRing and the saved-block case fails with 1. func TestKernelReportRing_BeforeFirstFetch(t *testing.T) { dir := t.TempDir() l := &Leg{PlanDir: dir} if got := l.kernelReportRing(); got != 1 { t.Fatalf("nothing fetched, nothing saved: ring %d, want 1 (the old default)", got) } l.saveBlock(&hub.WireOSUpdate{Ring: 0, Enabled: true}) l2 := &Leg{PlanDir: dir} // a fresh daemon after the reboot: no block fetched yet if got := l2.kernelReportRing(); got != 0 { t.Fatalf("ring-0 block saved before the reboot: ring %d, want 0", got) } l2.SetBlock(&hub.WireOSUpdate{Ring: 1, Enabled: true}) if got := l2.kernelReportRing(); got != 1 { t.Fatalf("a fetched block wins over the saved one: ring %d, want 1", got) } if _, err := os.Stat(filepath.Join(dir, SavedBlockFile)); err != nil { t.Fatalf("saved block missing: %v", err) } }