test(backup, scrobble, playevents, recsettings, apierror, auth, providers): merge repeated cases (#8299)
release / web (push) Successful in 1m41s
release / go (push) Successful in 2m4s
release / govulncheck (push) Successful in 23s
release / integration (push) Successful in 3m5s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Publish the release image to GHCR (dispatch only) (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / android (push) Canceled after 4m35s
release / Build signed APK (push) Canceled after 3m53s

- backup: schema coverage's three tests and the three AWS signing
  examples, one table each.
- scrobble: Qualifies' six boundary tests; the ListenBrainz client's
  refusal mapping, twelve tests of the same rule across three calls, one
  table over call x status; the two similarity lookups' success and URL
  tests, one table.
- playevents: the skip rule's three plays share one fixture. Dropped
  TestRecordPlayEnded_SubThreshold_NoEnqueue: the writer only calls
  scrobble.MaybeEnqueue, whose own test and Qualifies' table hold that
  case; the qualifying-play test still proves the writer calls it.
- recsettings: the three tag-scale tests share one database reset.
- apierror: Error() and From, one test each; auth: RequireAdmin's three.
- providers: GetJSON's not-found and transient answers, one table. Its
  two 401 tests expected the same answer with and without
  TreatAuthAsTransient, which changes only the error's text; the table
  says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 15:16:20 -05:00
co-authored by Claude Opus 5.5
parent b6454270b5
commit cfdbfa30e3
9 changed files with 306 additions and 628 deletions
+24 -17
View File
@@ -17,24 +17,31 @@ func everyListedTable() []string {
return names
}
func TestCoverageAcceptsASchemaThatMatchesTheLists(t *testing.T) {
if problems := Coverage(everyListedTable()); len(problems) != 0 {
t.Fatalf("problems = %v, want none", problems)
// Coverage holds the schema against the two lists: every table is backed up
// or excluded with a reason, and every listed table exists. A migration that
// adds or drops a table without updating the lists fails here.
func TestCoverage(t *testing.T) {
without := func(drop ...string) []string {
return slices.DeleteFunc(everyListedTable(), func(n string) bool { return slices.Contains(drop, n) })
}
}
func TestCoverageNamesATableInNeitherList(t *testing.T) {
problems := Coverage(append(everyListedTable(), "new_table"))
if len(problems) != 1 || !strings.HasPrefix(problems[0], "new_table: neither") {
t.Fatalf("problems = %v, want one naming new_table", problems)
}
}
func TestCoverageNamesAListedTableTheSchemaLacks(t *testing.T) {
schema := slices.DeleteFunc(everyListedTable(), func(n string) bool { return n == "playlists" || n == "scan_runs" })
problems := Coverage(schema)
if len(problems) != 2 {
t.Fatalf("problems = %v, want playlists and scan_runs named", problems)
for _, tc := range []struct {
name string
schema []string
want []string // a prefix of each problem, in order
}{
{"the schema matches the lists", everyListedTable(), nil},
{"a table in neither list", append(everyListedTable(), "new_table"), []string{"new_table: neither"}},
{"listed tables the schema lacks", without("playlists", "scan_runs"), []string{"playlists", "scan_runs"}},
} {
problems := Coverage(tc.schema)
slices.Sort(problems)
ok := len(problems) == len(tc.want)
for i := 0; ok && i < len(problems); i++ {
ok = strings.HasPrefix(problems[i], tc.want[i])
}
if !ok {
t.Errorf("%s: problems = %q, want ones starting %q", tc.name, problems, tc.want)
}
}
}