4c69c25b48
gates / gates (push) Successful in 50s
Unreleased; ships with tomorrow's release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
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)
|
|
}
|
|
}
|