release / govulncheck (push) Successful in 26s
release / web (push) Successful in 1m24s
release / go (push) Successful in 1m49s
release / integration (push) Successful in 4m36s
release / android (push) Successful in 6m15s
release / Build signed APK (releases and dev) (push) Successful in 6m30s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 27s
release / Verify release artifacts (tag releases only) (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package playlists_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
|
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
|
|
)
|
|
|
|
// A mix holds a song once (M498 #5438) and never a held-back video rip
|
|
// (#5439): of a single and its album cut, the better-ranked copy stays; a rip
|
|
// is left out and the next copy of its song takes the place.
|
|
func TestOneCopyPerSong_Integration(t *testing.T) {
|
|
pool := newPool(t)
|
|
ctx := context.Background()
|
|
q := dbq.New(pool)
|
|
single := seedTrack(t, pool, "copies-single", "copies-artist")
|
|
albumCut := seedTrack(t, pool, "copies-album-cut", "copies-artist")
|
|
rip := seedTrack(t, pool, "copies-rip", "copies-artist")
|
|
clean := seedTrack(t, pool, "copies-clean", "copies-artist")
|
|
other := seedTrack(t, pool, "copies-other", "copies-artist")
|
|
for _, pair := range [][]pgtype.UUID{{single.ID, albumCut.ID}, {rip.ID, clean.ID}} {
|
|
if _, err := q.LinkTracksAsSong(ctx, pair); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if _, err := pool.Exec(ctx, `UPDATE tracks SET source_verdict = 'suspect' WHERE id = $1`, rip.ID); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
in := []playlists.RankedCandidate{
|
|
{TrackID: single.ID}, {TrackID: rip.ID}, {TrackID: albumCut.ID}, {TrackID: other.ID}, {TrackID: clean.ID},
|
|
}
|
|
out, err := playlists.OneCopyPerSong(ctx, q, in)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []pgtype.UUID{single.ID, other.ID, clean.ID}
|
|
if len(out) != len(want) {
|
|
t.Fatalf("got %d tracks, want %d", len(out), len(want))
|
|
}
|
|
for i, w := range want {
|
|
if out[i].TrackID != w {
|
|
t.Errorf("position %d = %s, want %s", i, uuidString(out[i].TrackID), uuidString(w))
|
|
}
|
|
}
|
|
}
|