package hub import ( "os" "path/filepath" "testing" ) // R-840: the agent reports the bundle record itself — "none" when no bundle ever reached the box (so an old wrapper // cannot hide that), "unknown" when it cannot be read, else the version and sha the root wrapper recorded. func TestReadBundleRecord(t *testing.T) { dir := t.TempDir() p := filepath.Join(dir, "config-bundle.json") if got := string(readBundleRecord(p)); got != `{"version":"none"}` { t.Fatalf("absent: %s", got) } os.WriteFile(p, []byte("{broken"), 0o644) if got := string(readBundleRecord(p)); got != `{"version":"unknown"}` { t.Fatalf("broken: %s", got) } os.WriteFile(p, []byte(`{"format":1,"agent_version":"0.143.0","bundle_sha256":"abc","installed_at":"2026-10-04T20:00:00Z","authority":"signed","files":{"/x":"y"}}`), 0o644) if got := string(readBundleRecord(p)); got != `{"authority":"signed","bundle_sha256":"abc","installed_at":"2026-10-04T20:00:00Z","version":"0.143.0"}` { t.Fatalf("record: %s", got) } }