test(library): merge repeated cases into tables, drop tests of other code (#8296)
release / web (push) Successful in 1m30s
release / go (push) Successful in 1m57s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m26s
release / android (push) Successful in 4m40s
release / Build signed APK (push) Successful in 5m12s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 28s
release / Verify release artifacts (tag releases only) (push) Skipped
release / web (push) Successful in 1m30s
release / go (push) Successful in 1m57s
release / govulncheck (push) Successful in 19s
release / integration (push) Successful in 3m26s
release / android (push) Successful in 4m40s
release / Build signed APK (push) Successful in 5m12s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 28s
release / Verify release artifacts (tag releases only) (push) Skipped
- Moved-file adoption: 14 tests become one table. uniqueMatch, the row converters and pgtype's zero UUID are dropped: the adoption table covers the first two, and the third tests pgx. - Reconcile: marking and its change rows, and restoring and its change rows, are one test each; the five "a volume looks absent" refusals are one table. Dropped: an error-propagation test. - Genres: the ID3 reader cases, the normalisers and extractGenres across ID3, FLAC, Ogg and MP4 are one table each. - MusicBrainz tag ids: eleven per-format tests become one table. - Scan trigger: start / skip / reap is one table. Dropped: a closed-pool test. - Stage publisher: six tests become three. - Duplicate resolver: the cross-release cases (rip, renamed, kept as fine, two titles) asserted the same outcome once the resolver stopped removing files. They become one table that also checks the group's note, which is where rip and clean still differ. The auto-resolve-off song-link check moves into the existing auto-resolve-off test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,7 +120,7 @@ func TestResolveDuplicates_LinksASameReleaseCopyAndRemovesNothing_Integration(t
|
||||
}
|
||||
}
|
||||
|
||||
// With auto-resolve off, the pass classifies and removes nothing.
|
||||
// With auto-resolve off, the pass classifies, and links and removes nothing.
|
||||
func TestResolveDuplicates_ClassifiesOnlyWithoutPermission_Integration(t *testing.T) {
|
||||
f := newResolveFixture(t)
|
||||
res, err := ResolveDuplicates(context.Background(), f.pool, nil, false)
|
||||
@@ -134,6 +134,9 @@ func TestResolveDuplicates_ClassifiesOnlyWithoutPermission_Integration(t *testin
|
||||
if status != "pending" || class == nil || *class != string(ClassSameRelease) {
|
||||
t.Errorf("group = (%s, %v), want pending and classified", status, class)
|
||||
}
|
||||
if keys := songKeys(t, dbq.New(f.pool), f.clean.ID, f.rip.ID); keys[0] == keys[1] {
|
||||
t.Error("linked as one song with auto-resolve off")
|
||||
}
|
||||
}
|
||||
|
||||
// crossReleaseRipFixture is a video rip on one release with the clean copy on
|
||||
@@ -194,84 +197,61 @@ func newCrossReleaseRipFixture(t *testing.T) crossReleaseRipFixture {
|
||||
return f
|
||||
}
|
||||
|
||||
// A video rip on one release with the clean copy on another: both files stay,
|
||||
// the copies count as one song, and the group waits for an admin to remove
|
||||
// the rip.
|
||||
func TestResolveDuplicates_LinksARipAcrossReleasesAndRemovesNothing_Integration(t *testing.T) {
|
||||
f := newCrossReleaseRipFixture(t)
|
||||
res, err := ResolveDuplicates(context.Background(), f.pool, nil, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Classes[ClassCrossRelease] != 1 || res.SongsLinked != 1 {
|
||||
t.Fatalf("result %+v; want the cross-release group linked as one song", res)
|
||||
}
|
||||
if !exists(f.ripPath) || !exists(f.cleanPath) {
|
||||
t.Errorf("rip exists %v, clean exists %v; want both files left in place", exists(f.ripPath), exists(f.cleanPath))
|
||||
}
|
||||
if status, _, _, _ := (resolveFixture{pool: f.pool, groupID: f.groupID}).group(t); status != "pending" {
|
||||
t.Errorf("group = %s, want pending for an admin", status)
|
||||
}
|
||||
if n, _ := autoMergeAudit(t, f.pool, f.groupID); n != 0 {
|
||||
t.Errorf("automatic merge audit rows = %d, want none", n)
|
||||
}
|
||||
}
|
||||
|
||||
// Copies on two releases that are both clean each belong to their release:
|
||||
// nothing is removed, and they are linked as one song. A rip an admin
|
||||
// marked fine counts as clean.
|
||||
func TestResolveDuplicates_KeepsCleanCopiesOnTwoReleases_Integration(t *testing.T) {
|
||||
for name, prepare := range map[string]func(f crossReleaseRipFixture) (string, []any){
|
||||
"renamed": func(f crossReleaseRipFixture) (string, []any) {
|
||||
// Copies on separate releases (an album cut and the same song's single) are
|
||||
// linked as one song and every file stays. When all but one copy is named
|
||||
// like a video rip, the group's note asks an admin to merge; when every copy
|
||||
// is clean (named cleanly, kept as fine by an admin, or one recording under
|
||||
// two titles), each belongs to its release and the note says none is removed.
|
||||
func TestResolveDuplicates_LinksCopiesAcrossReleasesAndRemovesNothing_Integration(t *testing.T) {
|
||||
const ripNote, cleanNote = "named like a video rip", "none is removed"
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
prepare func(f crossReleaseRipFixture) (string, []any) // nil: the fixture as built
|
||||
wantNote string
|
||||
}{
|
||||
{"a rip beside the clean copy", nil, ripNote},
|
||||
{"the rip renamed", func(f crossReleaseRipFixture) (string, []any) {
|
||||
return `UPDATE tracks SET title = 'Feel Fine Ltd.', file_path = $2 WHERE id = $1`,
|
||||
[]any{f.rip.ID, filepath.Join(filepath.Dir(f.ripPath), "01 - Feel Fine Ltd.mp3")}
|
||||
},
|
||||
"kept as fine": func(f crossReleaseRipFixture) (string, []any) {
|
||||
}, cleanNote},
|
||||
{"the rip kept as fine", func(f crossReleaseRipFixture) (string, []any) {
|
||||
return `UPDATE tracks SET source_verdict = 'fine' WHERE id = $1`, []any{f.rip.ID}
|
||||
},
|
||||
}, cleanNote},
|
||||
// A later release retitled the recording; identical audio.
|
||||
{"one recording under two titles", func(f crossReleaseRipFixture) (string, []any) {
|
||||
return `WITH g AS (UPDATE duplicate_groups SET tier = 'exact' WHERE id = $3)
|
||||
UPDATE tracks SET title = 'DARE', file_path = $2 WHERE id = $1`,
|
||||
[]any{f.rip.ID, filepath.Join(filepath.Dir(f.ripPath), "01 - DARE.mp3"), f.groupID}
|
||||
}, cleanNote},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
f := newCrossReleaseRipFixture(t)
|
||||
sql, args := prepare(f)
|
||||
if _, err := f.pool.Exec(context.Background(), sql, args...); err != nil {
|
||||
t.Fatal(err)
|
||||
if tc.prepare != nil {
|
||||
sql, args := tc.prepare(f)
|
||||
if _, err := f.pool.Exec(context.Background(), sql, args...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
res, err := ResolveDuplicates(context.Background(), f.pool, nil, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !exists(f.ripPath) || !exists(f.cleanPath) {
|
||||
t.Errorf("result %+v; want both copies kept", res)
|
||||
if res.Classes[ClassCrossRelease] != 1 || res.SongsLinked != 1 {
|
||||
t.Fatalf("result %+v; want the cross-release group linked as one song", res)
|
||||
}
|
||||
if res.SongsLinked != 1 {
|
||||
t.Errorf("linked %d, want the pair linked as one song", res.SongsLinked)
|
||||
if !exists(f.ripPath) || !exists(f.cleanPath) {
|
||||
t.Errorf("rip exists %v, clean exists %v; want both files left in place", exists(f.ripPath), exists(f.cleanPath))
|
||||
}
|
||||
if note := noteOf(t, f.pool, f.groupID); !strings.Contains(note, tc.wantNote) {
|
||||
t.Errorf("note %q, want it to say %q", note, tc.wantNote)
|
||||
}
|
||||
if n, _ := autoMergeAudit(t, f.pool, f.groupID); n != 0 {
|
||||
t.Errorf("automatic merge audit rows = %d, want none", n)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Identical audio under two titles on two albums, neither a rip: a later
|
||||
// release retitled the recording ("F.O.E." and "F.O.E. (live)"). Each copy
|
||||
// belongs to its release, so nothing is removed and they count as one song.
|
||||
func TestResolveDuplicates_LinksOneRecordingUnderTwoTitles_Integration(t *testing.T) {
|
||||
f := newCrossReleaseRipFixture(t)
|
||||
ctx := context.Background()
|
||||
if _, err := f.pool.Exec(ctx, `UPDATE duplicate_groups SET tier = 'exact' WHERE id = $1`, f.groupID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := f.pool.Exec(ctx, `UPDATE tracks SET title = 'DARE', file_path = $2 WHERE id = $1`,
|
||||
f.rip.ID, filepath.Join(filepath.Dir(f.ripPath), "01 - DARE.mp3")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
res, err := ResolveDuplicates(ctx, f.pool, nil, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Classes[ClassCrossRelease] != 1 || res.SongsLinked != 1 || !exists(f.ripPath) || !exists(f.cleanPath) {
|
||||
t.Fatalf("result %+v; want the pair linked and kept", res)
|
||||
}
|
||||
}
|
||||
|
||||
// oneAlbumFixture is one album holding two tracks in one pending group, each
|
||||
// with a file on disk.
|
||||
type oneAlbumFixture struct {
|
||||
|
||||
Reference in New Issue
Block a user