Improve checker/fixer cohesion and harden workflows

This commit is contained in:
Julien Bisconti
2026-02-28 01:31:37 +01:00
parent e6e23bf1cf
commit c14a071c8d
12 changed files with 279 additions and 85 deletions

View File

@@ -89,6 +89,7 @@ func (hc *HealthCache) Merge(entries []HealthEntry) {
if i, exists := index[e.URL]; exists {
hc.Entries[i] = e
} else {
index[e.URL] = len(hc.Entries)
hc.Entries = append(hc.Entries, e)
}
}

View File

@@ -119,3 +119,19 @@ func TestMerge(t *testing.T) {
t.Errorf("last entry = %q, want C", hc.Entries[2].Name)
}
}
func TestMergeDeduplicatesIncomingBatch(t *testing.T) {
hc := &HealthCache{}
hc.Merge([]HealthEntry{
{URL: "https://github.com/c/c", Name: "C", Stars: 1},
{URL: "https://github.com/c/c", Name: "C", Stars: 2},
})
if len(hc.Entries) != 1 {
t.Fatalf("entries = %d, want 1", len(hc.Entries))
}
if hc.Entries[0].Stars != 2 {
t.Fatalf("stars = %d, want last value 2", hc.Entries[0].Stars)
}
}