test(playlists, recommendation): system-mix builds stop drawing covers no test reads; merge repeated cases (#8297)
release / go (push) Successful in 1m44s
release / web (push) Successful in 1m16s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m45s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m40s
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 14s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m44s
release / web (push) Successful in 1m16s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m45s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m40s
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 14s
release / Verify release artifacts (tag releases only) (push) Skipped
Timings from one run of the integration lane with -v (39c5b1ed, reverted
here) put the system-mix builds at 1.4-3.8s each, most of the playlists
package's 35s. A build draws a JPEG collage per mix; under -race that is
most of its time, and no build test looked at a cover. The build tests now
pass no data folder, which skips drawing, except SufficientActivity, which
keeps drawing and now checks every mix got a cover: nothing tested that the
build wires covers before.
Merged:
- playlists service: 22 tests become 5 scenario tests (access, bad input,
partial update, track-list edits, cover-file cleanup), one database
reset each.
- ARebuildKeepsEachMixsID into DailyNonceDeterminism (both built twice in
one day); the two You might like builds into one.
- capCandidatesByAlbumAndArtist, Score, Similarity, ContextualMatchScore
and the session-vector seed rule: one table each.
- LoadCandidates' six contextual-like database tests: the max and seed
rules are ContextualMatchScore's unit table; the database test keeps what
only it can see, a like reaching its track and a withdrawn like ignored.
Dropped: Score determinism with a fixed RNG (a pure function), Score's
cold-start case (the same input as the base case), and recencyDecay(nil)
and skipRatio's two cases, which Score's table covers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,57 +38,37 @@ func makeCand(trackN, albumN, artistN int, similarity float64) recommendation.Ca
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapCandidatesByAlbumAndArtist_AlbumCap(t *testing.T) {
|
||||
// discoverMaxTracksPerAlbum = 2: third track on album 10 must be dropped.
|
||||
in := []recommendation.Candidate{
|
||||
makeCand(1, 10, 100, 1.0),
|
||||
makeCand(2, 10, 101, 0.9),
|
||||
makeCand(3, 10, 102, 0.8), // 3rd from album 10 → drop
|
||||
makeCand(4, 11, 103, 0.7),
|
||||
}
|
||||
got := capCandidatesByAlbumAndArtist(in)
|
||||
if len(got) != 3 {
|
||||
t.Errorf("len = %d, want 3 (album 10 capped at 2)", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapCandidatesByAlbumAndArtist_ArtistCap(t *testing.T) {
|
||||
// discoverMaxTracksPerArtist = 3: fourth track by artist 100 must be dropped.
|
||||
in := []recommendation.Candidate{
|
||||
makeCand(1, 10, 100, 1.0),
|
||||
makeCand(2, 11, 100, 0.9),
|
||||
makeCand(3, 12, 100, 0.8),
|
||||
makeCand(4, 13, 100, 0.7), // 4th by artist 100 → drop
|
||||
makeCand(5, 14, 101, 0.6),
|
||||
}
|
||||
got := capCandidatesByAlbumAndArtist(in)
|
||||
if len(got) != 4 {
|
||||
t.Errorf("len = %d, want 4 (artist 100 capped at 3)", len(got))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapCandidatesByAlbumAndArtist_PreservesOrder(t *testing.T) {
|
||||
// All distinct albums and artists: all kept, original order preserved.
|
||||
in := []recommendation.Candidate{
|
||||
makeCand(3, 10, 100, 0.5),
|
||||
makeCand(1, 11, 101, 0.9),
|
||||
makeCand(2, 12, 102, 0.7),
|
||||
}
|
||||
got := capCandidatesByAlbumAndArtist(in)
|
||||
if len(got) != 3 {
|
||||
t.Fatalf("len = %d, want 3", len(got))
|
||||
}
|
||||
for i, want := range []byte{3, 1, 2} {
|
||||
if got[i].Track.ID.Bytes[15] != want {
|
||||
t.Errorf("got[%d].ID = %d, want %d", i, got[i].Track.ID.Bytes[15], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapCandidatesByAlbumAndArtist_Empty(t *testing.T) {
|
||||
got := capCandidatesByAlbumAndArtist(nil)
|
||||
if len(got) != 0 {
|
||||
t.Errorf("len = %d, want 0", len(got))
|
||||
// A mix keeps at most discoverMaxTracksPerAlbum (2) tracks from one album and
|
||||
// discoverMaxTracksPerArtist (3) by one artist, dropping the later ones and
|
||||
// keeping the order of the rest.
|
||||
func TestCapCandidatesByAlbumAndArtist(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
in []recommendation.Candidate
|
||||
want []byte // track numbers kept, in order
|
||||
}{
|
||||
{"a third track from one album", []recommendation.Candidate{
|
||||
makeCand(1, 10, 100, 1.0), makeCand(2, 10, 101, 0.9), makeCand(3, 10, 102, 0.8), makeCand(4, 11, 103, 0.7),
|
||||
}, []byte{1, 2, 4}},
|
||||
{"a fourth track by one artist", []recommendation.Candidate{
|
||||
makeCand(1, 10, 100, 1.0), makeCand(2, 11, 100, 0.9), makeCand(3, 12, 100, 0.8),
|
||||
makeCand(4, 13, 100, 0.7), makeCand(5, 14, 101, 0.6),
|
||||
}, []byte{1, 2, 3, 5}},
|
||||
{"nothing over a cap keeps its order", []recommendation.Candidate{
|
||||
makeCand(3, 10, 100, 0.5), makeCand(1, 11, 101, 0.9), makeCand(2, 12, 102, 0.7),
|
||||
}, []byte{3, 1, 2}},
|
||||
{"empty", nil, nil},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := capCandidatesByAlbumAndArtist(tc.in)
|
||||
ids := make([]byte, len(got))
|
||||
for i, c := range got {
|
||||
ids[i] = c.Track.ID.Bytes[15]
|
||||
}
|
||||
if string(ids) != string(tc.want) {
|
||||
t.Errorf("kept %v, want %v", ids, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user