test: invented artists, albums and MusicBrainz ids in place of real ones
release / web (push) Failing after 1m16s
release / go (push) Successful in 1m48s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m0s
release / android (push) Successful in 4m34s
release / Build signed APK (push) Successful in 5m9s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

Test data and example comments named real artists, records and songs, and
carried real MusicBrainz ids. One mapping swaps them for invented ones
throughout (Fields of Ontario, Plastic Apes, Marlo Davies, ...), keeping
what each case tests: sort order, index letter, escaping, title keys,
artist-prefix stripping. A test username is no longer the operator's name.

The cover-art and Last.fm connection checks still query real releases;
they reach live services and need something that exists there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 13:21:34 -05:00
co-authored by Claude Opus 5.5
parent 4244d81dfd
commit 4e1807cbba
80 changed files with 570 additions and 570 deletions
+4 -4
View File
@@ -28,14 +28,14 @@ func TestFoldDuplicateGroups(t *testing.T) {
rows := []dbq.ListPendingDuplicateGroupMembersRow{
// Group 1: identical audio, sizes tie, the older copy should be kept.
{GroupID: dupUUID(1), Tier: "exact", DetectedAt: dupTS(newer), TrackID: dupUUID(10),
Title: "WWW", FileFormat: "mp3", FileSize: 6_900_000, DurationMs: 215_400, AddedAt: dupTS(newer), PlayCount: 3},
Title: "XYZ", FileFormat: "mp3", FileSize: 6_900_000, DurationMs: 215_400, AddedAt: dupTS(newer), PlayCount: 3},
{GroupID: dupUUID(1), Tier: "exact", DetectedAt: dupTS(newer), TrackID: dupUUID(11),
Title: "WWW", FileFormat: "mp3", FileSize: 6_900_000, DurationMs: 215_400, AddedAt: dupTS(older), LikeCount: 1},
Title: "XYZ", FileFormat: "mp3", FileSize: 6_900_000, DurationMs: 215_400, AddedAt: dupTS(older), LikeCount: 1},
// Group 2: the same recording, FLAC against MP3.
{GroupID: dupUUID(2), Tier: "acoustic", WorstBitErrorRate: &ber, DetectedAt: dupTS(older), TrackID: dupUUID(20),
Title: "Lovesick", FileFormat: "mp3", FileSize: 9_000_000, DurationMs: 198_000, AddedAt: dupTS(older)},
Title: "Homesick", FileFormat: "mp3", FileSize: 9_000_000, DurationMs: 198_000, AddedAt: dupTS(older)},
{GroupID: dupUUID(2), Tier: "acoustic", WorstBitErrorRate: &ber, DetectedAt: dupTS(older), TrackID: dupUUID(21),
Title: "Lovesick", FileFormat: "flac", FileSize: 30_000_000, DurationMs: 198_000, AddedAt: dupTS(newer)},
Title: "Homesick", FileFormat: "flac", FileSize: 30_000_000, DurationMs: 198_000, AddedAt: dupTS(newer)},
}
got := foldDuplicateGroups(rows)
@@ -15,11 +15,11 @@ func TestHandleExportMissingTracks_Integration(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
admin := seedUser(t, pool, "export-admin", "pw", true)
artist := seedArtist(t, pool, "Boards of Canada")
album := seedAlbum(t, pool, artist.ID, "Geogaddi", 2002)
gone := seedTrack(t, pool, album.ID, artist.ID, "Music Is Math", 0, 300_000)
removed := seedTrack(t, pool, album.ID, artist.ID, "Dawn Chorus", 2, 240_000)
seedTrack(t, pool, album.ID, artist.ID, "Julie and Candy", 3, 200_000)
artist := seedArtist(t, pool, "Fields of Ontario")
album := seedAlbum(t, pool, artist.ID, "Geomantic", 2002)
gone := seedTrack(t, pool, album.ID, artist.ID, "Music Is Maps", 0, 300_000)
removed := seedTrack(t, pool, album.ID, artist.ID, "Dusk Chorus", 2, 240_000)
seedTrack(t, pool, album.ID, artist.ID, "Julia and Cane", 3, 200_000)
ctx := context.Background()
if _, err := pool.Exec(ctx, `UPDATE tracks SET missing_since = now() WHERE id = $1`, gone.ID); err != nil {
t.Fatal(err)
@@ -46,10 +46,10 @@ func TestHandleExportMissingTracks_Integration(t *testing.T) {
for _, r := range rows[1:] {
byTitle[r[4]] = r
}
if r := byTitle["Music Is Math"]; r == nil || r[3] != "" || r[5] != "" || r[7] != "missing" {
if r := byTitle["Music Is Maps"]; r == nil || r[3] != "" || r[5] != "" || r[7] != "missing" {
t.Errorf("untagged missing row = %v, want no track number, no mbid, why missing", r)
}
if r := byTitle["Dawn Chorus"]; r == nil || r[3] != "2" || r[5] != "rec-dawn" || r[7] != "report" {
if r := byTitle["Dusk Chorus"]; r == nil || r[3] != "2" || r[5] != "rec-dawn" || r[7] != "report" {
t.Errorf("removed row = %v, want track 2, its mbid, why report", r)
}
}
@@ -60,8 +60,8 @@ func TestHandleForgetMissingTracks_Integration(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
admin := seedUser(t, pool, "forget-admin", "pw", true)
artist := seedArtist(t, pool, "Autechre")
album := seedAlbum(t, pool, artist.ID, "Amber", 1994)
artist := seedArtist(t, pool, "Autoglyph")
album := seedAlbum(t, pool, artist.ID, "Ochre", 1994)
waiting := seedTrack(t, pool, album.ID, artist.ID, "Foil", 1, 300_000)
present := seedTrack(t, pool, album.ID, artist.ID, "Montreal", 2, 300_000)
ctx := context.Background()
+4 -4
View File
@@ -29,9 +29,9 @@ func TestGroupMissingByDirectory(t *testing.T) {
t.Run("consecutive rows in one directory collapse to one group", func(t *testing.T) {
groups := groupMissingByDirectory([]dbq.ListMissingTracksRow{
missingRow("/music/Linkin Park/Minutes to Midnight", "Given Up", base),
missingRow("/music/Linkin Park/Minutes to Midnight", "Leave Out All the Rest", base),
missingRow("/music/Linkin Park/Minutes to Midnight", "Bleed It Out", base),
missingRow("/music/Lincoln Yard/Minutes to Noon", "Given Up", base),
missingRow("/music/Lincoln Yard/Minutes to Noon", "Leave Out All the Rest", base),
missingRow("/music/Lincoln Yard/Minutes to Noon", "Bleed It Out", base),
})
if len(groups) != 1 {
@@ -40,7 +40,7 @@ func TestGroupMissingByDirectory(t *testing.T) {
if got := len(groups[0].Tracks); got != 3 {
t.Errorf("want 3 tracks in the group, got %d", got)
}
if groups[0].Directory != "/music/Linkin Park/Minutes to Midnight" {
if groups[0].Directory != "/music/Lincoln Yard/Minutes to Noon" {
t.Errorf("unexpected directory %q", groups[0].Directory)
}
})
+1 -1
View File
@@ -38,7 +38,7 @@ type suspectTrackView struct {
}
// suspectGroupView is a folder's worth of flagged tracks. As on the
// missing-files report, the folder is the unit of decision: Humanz was 62 rows
// missing-files report, the folder is the unit of decision: Mammalz was 62 rows
// in one folder, which is one problem to look at, not 62.
type suspectGroupView struct {
Directory string `json:"directory"`
+15 -15
View File
@@ -16,14 +16,14 @@ func TestHandleListSuspectSources_Integration(t *testing.T) {
truncateLibrary(t, pool)
admin := seedUser(t, pool, "suspect-admin", "pw", true)
artist := seedArtist(t, pool, "Gorillaz")
humanz := seedAlbum(t, pool, artist.ID, "Humanz", 2017)
seedTrack(t, pool, humanz.ID, artist.ID, "Saturnz Barz (Official Video)", 1, 180_000)
seedTrack(t, pool, humanz.ID, artist.ID, "Momentz (Visualizer)", 2, 200_000)
seedTrack(t, pool, humanz.ID, artist.ID, "Andromeda [Audio]", 3, 190_000)
seedTrack(t, pool, humanz.ID, artist.ID, "Chain Reaction", 4, 190_000)
seedTrack(t, pool, humanz.ID, artist.ID, "Busted and Blue", 5, 190_000)
gone := seedTrack(t, pool, humanz.ID, artist.ID, "Ascension (Lyric Video)", 6, 156_000)
artist := seedArtist(t, pool, "Plastic Apes")
mammalz := seedAlbum(t, pool, artist.ID, "Mammalz", 2017)
seedTrack(t, pool, mammalz.ID, artist.ID, "Neptunez Barz (Official Video)", 1, 180_000)
seedTrack(t, pool, mammalz.ID, artist.ID, "Minutez (Visualizer)", 2, 200_000)
seedTrack(t, pool, mammalz.ID, artist.ID, "Cassiopeia [Audio]", 3, 190_000)
seedTrack(t, pool, mammalz.ID, artist.ID, "Chain Reaction", 4, 190_000)
seedTrack(t, pool, mammalz.ID, artist.ID, "Bruised and Grey", 5, 190_000)
gone := seedTrack(t, pool, mammalz.ID, artist.ID, "Elevation (Lyric Video)", 6, 156_000)
if _, err := pool.Exec(context.Background(),
`UPDATE tracks SET missing_since = now() WHERE id = $1`, gone.ID); err != nil {
t.Fatalf("mark missing: %v", err)
@@ -54,9 +54,9 @@ func TestHandleListSuspectSources_Integration(t *testing.T) {
got[tr.Title] = tr.Markers
}
want := map[string][]string{
"Saturnz Barz (Official Video)": {"music video"},
"Momentz (Visualizer)": {"visualiser"},
"Andromeda [Audio]": {"[Audio]"},
"Neptunez Barz (Official Video)": {"music video"},
"Minutez (Visualizer)": {"visualiser"},
"Cassiopeia [Audio]": {"[Audio]"},
}
if len(got) != len(want) {
t.Fatalf("tracks = %v, want %v", got, want)
@@ -74,10 +74,10 @@ func TestHandleRemoveSuspectSourceFile_Integration(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
admin := seedUser(t, pool, "suspect-remover", "pw", true)
artist := seedArtist(t, pool, "Gorillaz")
humanz := seedAlbum(t, pool, artist.ID, "Humanz", 2017)
rip := seedTrack(t, pool, humanz.ID, artist.ID, "Saturnz Barz (Official Video)", 1, 180_000)
clean := seedTrack(t, pool, humanz.ID, artist.ID, "Chain Reaction", 4, 190_000)
artist := seedArtist(t, pool, "Plastic Apes")
mammalz := seedAlbum(t, pool, artist.ID, "Mammalz", 2017)
rip := seedTrack(t, pool, mammalz.ID, artist.ID, "Neptunez Barz (Official Video)", 1, 180_000)
clean := seedTrack(t, pool, mammalz.ID, artist.ID, "Chain Reaction", 4, 190_000)
remove := func(id string) int {
req := httptest.NewRequest(http.MethodPost, "/api/admin/library/suspect-sources/"+id+"/remove", nil)
+8 -8
View File
@@ -80,12 +80,12 @@ func TestCoverURLAndStreamURL(t *testing.T) {
func TestArtistRefFrom(t *testing.T) {
var id pgtype.UUID
_ = id.Scan("00112233-4455-6677-8899-aabbccddeeff")
a := dbq.Artist{ID: id, Name: "Beatles", SortName: "Beatles"}
a := dbq.Artist{ID: id, Name: "Copper Lanterns", SortName: "Copper Lanterns"}
got := artistRefFrom(a, 7)
if got.ID != "00112233-4455-6677-8899-aabbccddeeff" {
t.Errorf("ID = %q", got.ID)
}
if got.Name != "Beatles" || got.AlbumCount != 7 {
if got.Name != "Copper Lanterns" || got.AlbumCount != 7 {
t.Errorf("ref = %+v", got)
}
}
@@ -96,9 +96,9 @@ func TestAlbumRefFrom(t *testing.T) {
_ = artID.Scan("00000000-0000-0000-0000-000000000002")
var rel pgtype.Date
_ = rel.Scan("1969-09-26")
a := dbq.Album{ID: aid, Title: "Abbey Road", ArtistID: artID, ReleaseDate: rel}
got := albumRefFrom(a, "Beatles", 17, 2820)
if got.Title != "Abbey Road" || got.ArtistName != "Beatles" {
a := dbq.Album{ID: aid, Title: "Harbour Street", ArtistID: artID, ReleaseDate: rel}
got := albumRefFrom(a, "Copper Lanterns", 17, 2820)
if got.Title != "Harbour Street" || got.ArtistName != "Copper Lanterns" {
t.Errorf("ref = %+v", got)
}
if got.TrackCount != 17 || got.DurationSec != 2820 {
@@ -120,12 +120,12 @@ func TestTrackRefFrom(t *testing.T) {
trackNum := int32(3)
discNum := int32(1)
t2 := dbq.Track{
ID: tid, Title: "Something", AlbumID: aid, ArtistID: artID,
ID: tid, Title: "Somewhere Near", AlbumID: aid, ArtistID: artID,
TrackNumber: &trackNum, DiscNumber: &discNum,
DurationMs: 183_000,
}
got := trackRefFrom(t2, "Abbey Road", "Beatles")
if got.Title != "Something" || got.AlbumTitle != "Abbey Road" || got.ArtistName != "Beatles" {
got := trackRefFrom(t2, "Harbour Street", "Copper Lanterns")
if got.Title != "Somewhere Near" || got.AlbumTitle != "Harbour Street" || got.ArtistName != "Copper Lanterns" {
t.Errorf("ref = %+v", got)
}
if got.TrackNumber != 3 || got.DiscNumber != 1 {
+4 -4
View File
@@ -28,8 +28,8 @@ func TestHandleEvents_PlayStartedReturnsIDs(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
user := seedUser(t, pool, "alice", "x", false)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Something", 3, 183_000)
body, _ := json.Marshal(map[string]any{
@@ -56,8 +56,8 @@ func TestHandleEvents_PlayEndedClosesRow(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
user := seedUser(t, pool, "alice", "x", false)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Something", 3, 183_000)
startedID := postPlayStartedHelper(t, h, user, track.ID)
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"git.fabledsword.com/bvandeusen/minstrel/internal/library"
)
const removeTestPath = "/music/Moe Shop/WWW (2020)/01 - WWW.mp3"
const removeTestPath = "/music/Mochi Shop/XYZ (2020)/01 - XYZ.mp3"
// removeFailure builds the error a delete service returns when the file would
// not go, wrapped the way quarantine.DeleteFile and quarantine.RemoveFile
@@ -35,7 +35,7 @@ func TestFileRemoveAPIError(t *testing.T) {
{
name: "read-only mount", errno: syscall.EROFS,
wantStatus: http.StatusConflict, wantCode: "library_not_writable",
wantIn: []string{"uid 1000, gid 1000", "/music/Moe Shop/WWW (2020)", "read-only file system", "Nothing was deleted"},
wantIn: []string{"uid 1000, gid 1000", "/music/Mochi Shop/XYZ (2020)", "read-only file system", "Nothing was deleted"},
},
{
name: "permission denied", errno: syscall.EACCES,
@@ -77,7 +77,7 @@ func TestFileRemoveAPIError(t *testing.T) {
// plain "contains the directory" check could never catch that regression.
func TestFileRemoveAPIError_NotWritableNamesTheDirectoryNotTheFile(t *testing.T) {
apiErr, _ := fileRemoveAPIError(removeFailure(syscall.EROFS))
if strings.Contains(apiErr.Message, "01 - WWW.mp3") {
if strings.Contains(apiErr.Message, "01 - XYZ.mp3") {
t.Fatalf("message names the file rather than its directory: %q", apiErr.Message)
}
}
+1 -1
View File
@@ -53,7 +53,7 @@ func TestLibrarySync_AfterArtistUpsert_ReturnsHydratedPayload(t *testing.T) {
var artistID string
if err := tx.QueryRow(ctx,
`INSERT INTO artists (name, sort_name) VALUES ($1, $2) RETURNING id::text`,
"Boards of Canada", "Boards of Canada",
"Fields of Ontario", "Fields of Ontario",
).Scan(&artistID); err != nil {
t.Fatalf("insert artist: %v", err)
}
+3 -3
View File
@@ -41,7 +41,7 @@ func assertJSONKeys(t *testing.T, label string, b []byte, want []string) {
}
func TestArtistSyncView_WireKeys(t *testing.T) {
a := dbq.Artist{ID: validUUID, Name: "Aphex Twin", SortName: "Aphex Twin"}
a := dbq.Artist{ID: validUUID, Name: "Apex Sibling", SortName: "Apex Sibling"}
b, err := json.Marshal(toArtistSyncView(a))
if err != nil {
t.Fatal(err)
@@ -53,7 +53,7 @@ func TestArtistSyncView_WireKeys(t *testing.T) {
}
func TestAlbumSyncView_WireKeys(t *testing.T) {
a := dbq.Album{ID: validUUID, ArtistID: validUUID, Title: "Drukqs", SortTitle: "Drukqs"}
a := dbq.Album{ID: validUUID, ArtistID: validUUID, Title: "Drumkits", SortTitle: "Drumkits"}
b, err := json.Marshal(toAlbumSyncView(a, library.ReplayGain{}))
if err != nil {
t.Fatal(err)
@@ -67,7 +67,7 @@ func TestAlbumSyncView_WireKeys(t *testing.T) {
func TestTrackSyncView_WireKeys(t *testing.T) {
tr := dbq.Track{
ID: validUUID, AlbumID: validUUID, ArtistID: validUUID,
Title: "Avril 14th", DurationMs: 121_000,
Title: "Juin 21st", DurationMs: 121_000,
FilePath: "x", FileFormat: "flac",
}
b, err := json.Marshal(toTrackSyncView(tr, library.ReplayGain{}))
+25 -25
View File
@@ -59,9 +59,9 @@ func injectFakeUserForTest(next http.Handler) http.Handler {
func TestHandleGetTrack_HappyPath(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Something", 3, 183_000)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Somewhere Near", 3, 183_000)
req := httptest.NewRequest(http.MethodGet, "/api/tracks/"+uuidToString(track.ID), nil)
w := httptest.NewRecorder()
@@ -74,7 +74,7 @@ func TestHandleGetTrack_HappyPath(t *testing.T) {
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
t.Fatalf("decode: %v body=%s", err, w.Body.String())
}
if got.Title != "Something" || got.AlbumTitle != "Abbey Road" || got.ArtistName != "Beatles" {
if got.Title != "Somewhere Near" || got.AlbumTitle != "Harbour Street" || got.ArtistName != "Copper Lanterns" {
t.Errorf("ref = %+v", got)
}
if got.TrackNumber != 3 || got.DurationSec != 183 {
@@ -111,10 +111,10 @@ func TestHandleGetTrack_NotFound(t *testing.T) {
func TestHandleGetAlbum_HappyPath(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
seedTrack(t, pool, album.ID, artist.ID, "Come Together", 1, 259_000)
seedTrack(t, pool, album.ID, artist.ID, "Something", 2, 183_000)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
seedTrack(t, pool, album.ID, artist.ID, "Come Along", 1, 259_000)
seedTrack(t, pool, album.ID, artist.ID, "Somewhere Near", 2, 183_000)
req := httptest.NewRequest(http.MethodGet, "/api/albums/"+uuidToString(album.ID), nil)
w := httptest.NewRecorder()
@@ -127,13 +127,13 @@ func TestHandleGetAlbum_HappyPath(t *testing.T) {
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
t.Fatalf("decode: %v body=%s", err, w.Body.String())
}
if got.Title != "Abbey Road" || got.ArtistName != "Beatles" || got.Year != 1969 {
if got.Title != "Harbour Street" || got.ArtistName != "Copper Lanterns" || got.Year != 1969 {
t.Errorf("album = %+v", got)
}
if len(got.Tracks) != 2 {
t.Fatalf("tracks len = %d, want 2", len(got.Tracks))
}
if got.Tracks[0].Title != "Come Together" || got.Tracks[1].Title != "Something" {
if got.Tracks[0].Title != "Come Along" || got.Tracks[1].Title != "Somewhere Near" {
t.Errorf("tracks = %+v", got.Tracks)
}
if got.TrackCount != 2 || got.DurationSec != 442 { // 259 + 183
@@ -180,7 +180,7 @@ func TestHandleGetAlbum_EachTrackNamesItsOwnArtist(t *testing.T) {
func TestHandleGetAlbum_NoTracks(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
artist := seedArtist(t, pool, "Beatles")
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Empty", 0)
req := httptest.NewRequest(http.MethodGet, "/api/albums/"+uuidToString(album.ID), nil)
@@ -230,11 +230,11 @@ func TestHandleGetAlbum_NotFound(t *testing.T) {
func TestHandleGetArtist_HappyPath(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
artist := seedArtist(t, pool, "Beatles")
album1 := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
album2 := seedAlbum(t, pool, artist.ID, "Let It Be", 1970)
seedTrack(t, pool, album1.ID, artist.ID, "Something", 3, 183_000)
seedTrack(t, pool, album2.ID, artist.ID, "Get Back", 1, 189_000)
artist := seedArtist(t, pool, "Copper Lanterns")
album1 := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
album2 := seedAlbum(t, pool, artist.ID, "Let It Ride", 1970)
seedTrack(t, pool, album1.ID, artist.ID, "Somewhere Near", 3, 183_000)
seedTrack(t, pool, album2.ID, artist.ID, "Get Going", 1, 189_000)
req := httptest.NewRequest(http.MethodGet, "/api/artists/"+uuidToString(artist.ID), nil)
w := httptest.NewRecorder()
@@ -247,7 +247,7 @@ func TestHandleGetArtist_HappyPath(t *testing.T) {
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
t.Fatalf("decode: %v body=%s", err, w.Body.String())
}
if got.Name != "Beatles" {
if got.Name != "Copper Lanterns" {
t.Errorf("name = %q", got.Name)
}
if got.AlbumCount != 2 {
@@ -256,13 +256,13 @@ func TestHandleGetArtist_HappyPath(t *testing.T) {
if len(got.Albums) != 2 {
t.Fatalf("albums len = %d, want 2", len(got.Albums))
}
// ListAlbumsByArtist orders by release_date then sort_title; Abbey Road
// ListAlbumsByArtist orders by release_date then sort_title; Harbour Street
// (1969) first.
if got.Albums[0].Title != "Abbey Road" {
t.Errorf("first album = %q, want Abbey Road", got.Albums[0].Title)
if got.Albums[0].Title != "Harbour Street" {
t.Errorf("first album = %q, want Harbour Street", got.Albums[0].Title)
}
for _, a := range got.Albums {
if a.ArtistName != "Beatles" {
if a.ArtistName != "Copper Lanterns" {
t.Errorf("album.artist_name = %q", a.ArtistName)
}
if a.CoverURL == "" {
@@ -321,9 +321,9 @@ func TestHandleGetArtist_NotFound(t *testing.T) {
func TestHandleListArtists_DefaultAlpha(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
seedArtist(t, pool, "Beatles")
seedArtist(t, pool, "ABBA")
seedArtist(t, pool, "Zeppelin")
seedArtist(t, pool, "Copper Lanterns")
seedArtist(t, pool, "ABAB")
seedArtist(t, pool, "Zephyrine")
req := httptest.NewRequest(http.MethodGet, "/api/artists", nil)
w := httptest.NewRecorder()
@@ -345,7 +345,7 @@ func TestHandleListArtists_DefaultAlpha(t *testing.T) {
if len(got.Items) != 3 {
t.Fatalf("items len = %d", len(got.Items))
}
if got.Items[0].Name != "ABBA" || got.Items[2].Name != "Zeppelin" {
if got.Items[0].Name != "ABAB" || got.Items[2].Name != "Zephyrine" {
t.Errorf("alpha order wrong: %q, %q, %q", got.Items[0].Name, got.Items[1].Name, got.Items[2].Name)
}
}
+4 -4
View File
@@ -41,8 +41,8 @@ func TestLikeTrack_Idempotent(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
user := seedUser(t, pool, "alice", "x", false)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Something", 3, 183_000)
w := callLike(h, user, http.MethodPost, "/api/likes/tracks/"+uuidToString(track.ID))
@@ -84,8 +84,8 @@ func TestUnlikeTrack_IdempotentEvenWhenAbsent(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
user := seedUser(t, pool, "alice", "x", false)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Abbey Road", 1969)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Harbour Street", 1969)
track := seedTrack(t, pool, album.ID, artist.ID, "Something", 3, 183_000)
w := callLike(h, user, http.MethodDelete, "/api/likes/tracks/"+uuidToString(track.ID))
+8 -8
View File
@@ -10,11 +10,11 @@ import (
func TestHandleSearch_ThreeFacets(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
artist := seedArtist(t, pool, "Beatles")
album := seedAlbum(t, pool, artist.ID, "Beatles Greatest", 1982)
seedTrack(t, pool, album.ID, artist.ID, "Beatles Jam", 1, 60_000)
artist := seedArtist(t, pool, "Copper Lanterns")
album := seedAlbum(t, pool, artist.ID, "Copper Lanterns Greatest", 1982)
seedTrack(t, pool, album.ID, artist.ID, "Copper Lanterns Jam", 1, 60_000)
req := httptest.NewRequest(http.MethodGet, "/api/search?q=beatles", nil)
req := httptest.NewRequest(http.MethodGet, "/api/search?q=copper", nil)
w := httptest.NewRecorder()
newLibraryRouter(h).ServeHTTP(w, req)
@@ -34,13 +34,13 @@ func TestHandleSearch_ThreeFacets(t *testing.T) {
if got.Tracks.Total != 1 || len(got.Tracks.Items) != 1 {
t.Errorf("tracks = %+v", got.Tracks)
}
if got.Artists.Items[0].Name != "Beatles" {
if got.Artists.Items[0].Name != "Copper Lanterns" {
t.Errorf("artist name = %q", got.Artists.Items[0].Name)
}
if got.Albums.Items[0].ArtistName != "Beatles" {
if got.Albums.Items[0].ArtistName != "Copper Lanterns" {
t.Errorf("album.artist_name = %q", got.Albums.Items[0].ArtistName)
}
if got.Tracks.Items[0].AlbumTitle != "Beatles Greatest" {
if got.Tracks.Items[0].AlbumTitle != "Copper Lanterns Greatest" {
t.Errorf("track.album_title = %q", got.Tracks.Items[0].AlbumTitle)
}
}
@@ -48,7 +48,7 @@ func TestHandleSearch_ThreeFacets(t *testing.T) {
func TestHandleSearch_NoMatches(t *testing.T) {
h, pool := testHandlers(t)
truncateLibrary(t, pool)
seedArtist(t, pool, "Beatles")
seedArtist(t, pool, "Copper Lanterns")
req := httptest.NewRequest(http.MethodGet, "/api/search?q=nothinghere", nil)
w := httptest.NewRecorder()
+1 -1
View File
@@ -42,7 +42,7 @@ type Page[T any] struct {
// ArtistRef is the lightweight artist shape used in lists and search results.
// SortName is exposed so the SPA's alphabetical-grid divider can group rows
// by the catalogue sort order ("The Beatles" → "B"). CoverURL is derived from
// by the catalogue sort order ("The Copper Lanterns" → "C"). CoverURL is derived from
// a representative album (most-recent with cover_art_path); empty when the
// artist's discography has no cover art.
type ArtistRef struct {