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>
81 lines
2.6 KiB
Go
81 lines
2.6 KiB
Go
package playlists_test
|
||
|
||
import (
|
||
"context"
|
||
"testing"
|
||
"time"
|
||
|
||
"github.com/jackc/pgx/v5/pgtype"
|
||
"github.com/jackc/pgx/v5/pgxpool"
|
||
|
||
"github.com/Fabled-Sword/minstrel/internal/dbtest"
|
||
"github.com/Fabled-Sword/minstrel/internal/playlists"
|
||
)
|
||
|
||
// countYouMightLike returns the persisted row counts for a user.
|
||
func countYouMightLike(t *testing.T, pool *pgxpool.Pool, userID pgtype.UUID) (albums, artists int) {
|
||
t.Helper()
|
||
ctx := context.Background()
|
||
if err := pool.QueryRow(ctx,
|
||
`SELECT count(*) FROM you_might_like_albums WHERE user_id = $1`, userID,
|
||
).Scan(&albums); err != nil {
|
||
t.Fatalf("count albums: %v", err)
|
||
}
|
||
if err := pool.QueryRow(ctx,
|
||
`SELECT count(*) FROM you_might_like_artists WHERE user_id = $1`, userID,
|
||
).Scan(&artists); err != nil {
|
||
t.Fatalf("count artists: %v", err)
|
||
}
|
||
return albums, artists
|
||
}
|
||
|
||
// TestYouMightLike_ColdStartGate: a thin profile (3 artists × 3 tracks =
|
||
// 9 distinct tracks, below the 20-track / 5-artist gate) must produce no
|
||
// You-might-like rows — the build ships nothing rather than near-random
|
||
// tiles.
|
||
func TestYouMightLike_ColdStartGate(t *testing.T) {
|
||
pool := dbtest.Pool(t)
|
||
logger := discardLogger()
|
||
u, _ := seedActiveLibrary(t, pool, "ymlcold", 3, 3)
|
||
|
||
if err := playlists.BuildSystemPlaylists(
|
||
context.Background(), pool, logger, u.ID, time.Now().UTC(), "",
|
||
); err != nil {
|
||
t.Fatalf("build: %v", err)
|
||
}
|
||
|
||
albums, artists := countYouMightLike(t, pool, u.ID)
|
||
if albums != 0 || artists != 0 {
|
||
t.Errorf("cold-start user should have no you-might-like rows; got %d albums, %d artists",
|
||
albums, artists)
|
||
}
|
||
}
|
||
|
||
// A rich profile (8 artists × 4 tracks = 32 distinct tracks, clearing both
|
||
// gate bars) populates the You-might-like tables in the daily build, and a
|
||
// second build replaces those rows rather than adding to them, so the counts
|
||
// stay within the persisted depth.
|
||
func TestYouMightLike_PopulatesAndAReplaceKeepsTheDepth(t *testing.T) {
|
||
pool := dbtest.Pool(t)
|
||
logger := discardLogger()
|
||
u, _ := seedActiveLibrary(t, pool, "ymlrich", 8, 4)
|
||
ctx := context.Background()
|
||
build := func() {
|
||
t.Helper()
|
||
if err := playlists.BuildSystemPlaylists(ctx, pool, logger, u.ID, time.Now().UTC(), ""); err != nil {
|
||
t.Fatalf("build: %v", err)
|
||
}
|
||
}
|
||
|
||
build()
|
||
albums, artists := countYouMightLike(t, pool, u.ID)
|
||
if albums == 0 || artists == 0 {
|
||
t.Fatalf("rich user has %d album and %d artist rows; want some of each", albums, artists)
|
||
}
|
||
build()
|
||
albums, artists = countYouMightLike(t, pool, u.ID)
|
||
if albums > 12 || artists > 12 {
|
||
t.Errorf("after two builds: %d albums, %d artists; want <= 12 each (atomic replace)", albums, artists)
|
||
}
|
||
}
|