fix(server,web/m7-cover-sources): forward-fix CI
Three failures from the prior push: 1. internal/api/library.go and 3 other callers of q.GetArtistByID broke because T2 modified the query to use an explicit column list, making sqlc generate GetArtistByIDRow instead of returning dbq.Artist. dbq.Artist already has every column added by migration 0018 (artist_thumb_path / artist_fanart_path / artist_art_source / artist_art_sources_version), so the explicit column list was unnecessary work. Revert the SELECT to SELECT *, regenerate sqlc, GetArtistByIDRow disappears, all callers compile again. 2. internal/tracks/service_test.go missed the dataDir parameter added to NewService in T9. Add "" as the 4th arg to every test call site (tests don't exercise the artist-art cleanup path; the empty dataDir is fine). 3. integrations.test.ts:356's mock.calls.filter callback had a too-narrow type annotation that svelte-check rejected. Relax to any[] to match what mock.calls actually is.
This commit is contained in:
@@ -67,36 +67,21 @@ func (q *Queries) DeleteArtistIfEmpty(ctx context.Context, id pgtype.UUID) (pgty
|
||||
}
|
||||
|
||||
const getArtistByID = `-- name: GetArtistByID :one
|
||||
SELECT a.id, a.name, a.sort_name, a.mbid,
|
||||
a.artist_thumb_path, a.artist_fanart_path,
|
||||
a.artist_art_source, a.artist_art_sources_version
|
||||
FROM artists a
|
||||
WHERE a.id = $1
|
||||
SELECT id, name, sort_name, mbid, created_at, updated_at, artist_thumb_path, artist_fanart_path, artist_art_source, artist_art_sources_version FROM artists WHERE id = $1
|
||||
`
|
||||
|
||||
type GetArtistByIDRow struct {
|
||||
ID pgtype.UUID
|
||||
Name string
|
||||
SortName string
|
||||
Mbid *string
|
||||
ArtistThumbPath *string
|
||||
ArtistFanartPath *string
|
||||
ArtistArtSource *string
|
||||
ArtistArtSourcesVersion int32
|
||||
}
|
||||
|
||||
// M7 cover-sources: enricher reads the artist's mbid + current art
|
||||
// columns to drive eligibility check. (Modified from SELECT * to
|
||||
// explicitly include the new artist_art_* columns added in migration
|
||||
// 0018.)
|
||||
func (q *Queries) GetArtistByID(ctx context.Context, id pgtype.UUID) (GetArtistByIDRow, error) {
|
||||
// Lookup an artist row by its UUID. Returns the full row; consumers
|
||||
// pick the columns they need.
|
||||
func (q *Queries) GetArtistByID(ctx context.Context, id pgtype.UUID) (Artist, error) {
|
||||
row := q.db.QueryRow(ctx, getArtistByID, id)
|
||||
var i GetArtistByIDRow
|
||||
var i Artist
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.SortName,
|
||||
&i.Mbid,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ArtistThumbPath,
|
||||
&i.ArtistFanartPath,
|
||||
&i.ArtistArtSource,
|
||||
|
||||
@@ -11,15 +11,9 @@ DO UPDATE SET
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetArtistByID :one
|
||||
-- M7 cover-sources: enricher reads the artist's mbid + current art
|
||||
-- columns to drive eligibility check. (Modified from SELECT * to
|
||||
-- explicitly include the new artist_art_* columns added in migration
|
||||
-- 0018.)
|
||||
SELECT a.id, a.name, a.sort_name, a.mbid,
|
||||
a.artist_thumb_path, a.artist_fanart_path,
|
||||
a.artist_art_source, a.artist_art_sources_version
|
||||
FROM artists a
|
||||
WHERE a.id = $1;
|
||||
-- Lookup an artist row by its UUID. Returns the full row; consumers
|
||||
-- pick the columns they need.
|
||||
SELECT * FROM artists WHERE id = $1;
|
||||
|
||||
-- name: GetArtistByName :one
|
||||
SELECT * FROM artists WHERE name = $1 LIMIT 1;
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestRemoveTrack_NotFound(t *testing.T) {
|
||||
bogus.Bytes = [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
||||
bogus.Valid = true
|
||||
|
||||
svc := NewService(pool, nil, nil)
|
||||
svc := NewService(pool, nil, nil, "")
|
||||
_, _, _, err := svc.RemoveTrack(context.Background(), bogus, admin.ID, false)
|
||||
if !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("err = %v, want ErrNotFound", err)
|
||||
@@ -142,7 +142,7 @@ func TestRemoveTrack_LocalFile_HappyPath(t *testing.T) {
|
||||
_, _, track := seedArtistAlbumTrack(t, pool, "Solo", "", path)
|
||||
|
||||
fake := &fakeLidarrUnmonitorer{}
|
||||
svc := NewService(pool, nil, fake)
|
||||
svc := NewService(pool, nil, fake, "")
|
||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -170,7 +170,7 @@ func TestRemoveTrack_FileAlreadyMissing(t *testing.T) {
|
||||
missing := filepath.Join(t.TempDir(), "does-not-exist.mp3")
|
||||
_, _, track := seedArtistAlbumTrack(t, pool, "Ghost", "", missing)
|
||||
|
||||
svc := NewService(pool, nil, nil)
|
||||
svc := NewService(pool, nil, nil, "")
|
||||
_, _, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -226,7 +226,7 @@ func TestRemoveTrack_Cascade_AlbumEmpty(t *testing.T) {
|
||||
t.Fatalf("trackB: %v", err)
|
||||
}
|
||||
|
||||
svc := NewService(pool, nil, nil)
|
||||
svc := NewService(pool, nil, nil, "")
|
||||
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), trackA.ID, admin.ID, false)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -259,7 +259,7 @@ func TestRemoveTrack_Cascade_ArtistEmpty(t *testing.T) {
|
||||
}
|
||||
artist, album, track := seedArtistAlbumTrack(t, pool, "Lone", "", path)
|
||||
|
||||
svc := NewService(pool, nil, nil)
|
||||
svc := NewService(pool, nil, nil, "")
|
||||
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -325,7 +325,7 @@ func TestRemoveTrack_Unmonitor_HappyPath(t *testing.T) {
|
||||
}
|
||||
|
||||
fake := &fakeLidarrUnmonitorer{}
|
||||
svc := NewService(pool, nil, fake)
|
||||
svc := NewService(pool, nil, fake, "")
|
||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -381,7 +381,7 @@ func TestRemoveTrack_Unmonitor_LidarrErrorIsNonFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
fake := &fakeLidarrUnmonitorer{err: errors.New("simulated lidarr 5xx")}
|
||||
svc := NewService(pool, nil, fake)
|
||||
svc := NewService(pool, nil, fake, "")
|
||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v (want nil — Lidarr failure is non-fatal)", err)
|
||||
@@ -411,7 +411,7 @@ func TestRemoveTrack_Unmonitor_NoMbidSkipsLidarr(t *testing.T) {
|
||||
_, _, track := seedArtistAlbumTrack(t, pool, "Local", "", path)
|
||||
|
||||
fake := &fakeLidarrUnmonitorer{}
|
||||
svc := NewService(pool, nil, fake)
|
||||
svc := NewService(pool, nil, fake, "")
|
||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
@@ -437,7 +437,7 @@ func TestRemoveTrack_NoUnmonitor_SkipsLidarr(t *testing.T) {
|
||||
_, _, track := seedArtistAlbumTrack(t, pool, "NoMon", "track-mbid", path)
|
||||
|
||||
fake := &fakeLidarrUnmonitorer{}
|
||||
svc := NewService(pool, nil, fake)
|
||||
svc := NewService(pool, nil, fake, "")
|
||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||
if err != nil {
|
||||
t.Fatalf("RemoveTrack: %v", err)
|
||||
|
||||
@@ -353,7 +353,7 @@ describe('/admin/integrations — cover art providers', () => {
|
||||
});
|
||||
// coverage invalidation should NOT have been called
|
||||
const coverageCalls = invalidateQueries.mock.calls.filter(
|
||||
(call: [{ queryKey: unknown[] }]) => JSON.stringify(call[0]?.queryKey) === JSON.stringify(['coverage'])
|
||||
(call: any[]) => JSON.stringify(call[0]?.queryKey) === JSON.stringify(['coverage'])
|
||||
);
|
||||
expect(coverageCalls.length).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user