package report import ( "encoding/json" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/system" ) // R-266: a failed root statfs reaches the hub as read_failed, not as a 0-of-0 disk the hub would band // as "0 % used". A measured disk carries no read_failed at all (omitempty), so an old hub sees no change. func TestRootStorageEntry_ReadFailed(t *testing.T) { failed := rootStorageEntry(system.SystemInfo{DiskKnown: false}) if !failed.ReadFailed { t.Fatal("root statfs failed (DiskKnown false) but the storage entry does not say read_failed") } if failed.TotalGB != 0 || failed.UsedGB != 0 || failed.Percent != 0 || failed.Mount != "/" { t.Errorf("failed entry changed its numbers or mount: %+v", failed) } b, _ := json.Marshal(failed) if !strings.Contains(string(b), `"read_failed":true`) { t.Errorf("wire form lacks read_failed: %s", b) } ok := rootStorageEntry(system.SystemInfo{DiskKnown: true, DiskTotalGB: 100, DiskUsedGB: 40, DiskPercent: 40}) if ok.ReadFailed { t.Error("a measured root disk is marked read_failed") } b, _ = json.Marshal(ok) if strings.Contains(string(b), "read_failed") { t.Errorf("a measured disk must not carry read_failed on the wire: %s", b) } if ok.TotalGB != 100 || ok.Percent != 40 { t.Errorf("measured numbers lost: %+v", ok) } }