package store import "testing" func TestDecodeWarnings(t *testing.T) { old := decodeWarnings(`["Only 3 of 9 folders match."]`) if len(old) != 1 || old[0].Title != "Only 3 of 9 folders match." { t.Fatalf("plain-string warnings from older scans should decode as titles, got %+v", old) } cur := decodeWarnings(`[{"title":"t","items":[{"slave":"a","master":"b","count":2}],"total":5}]`) if len(cur) != 1 || cur[0].Total != 5 || cur[0].Items[0].Count != 2 { t.Fatalf("structured warnings should round-trip, got %+v", cur) } if ws := decodeWarnings(`[]`); ws == nil || len(ws) != 0 { t.Fatalf("empty list should stay an empty (non-nil) list, got %#v", ws) } }