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>
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
package backup
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func everyListedTable() []string {
|
|
var names []string
|
|
for _, t := range Tables {
|
|
names = append(names, t.Name)
|
|
}
|
|
for name := range Excluded {
|
|
names = append(names, name)
|
|
}
|
|
return names
|
|
}
|
|
|
|
// 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) })
|
|
}
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestEveryExclusionHasAReason(t *testing.T) {
|
|
for name, why := range Excluded {
|
|
if strings.TrimSpace(why) == "" {
|
|
t.Errorf("%s is excluded without a reason", name)
|
|
}
|
|
if carried(name) {
|
|
t.Errorf("%s is both backed up and excluded", name)
|
|
}
|
|
}
|
|
}
|