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
|
const getArtistByID = `-- name: GetArtistByID :one
|
||||||
SELECT a.id, a.name, a.sort_name, a.mbid,
|
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
|
||||||
a.artist_thumb_path, a.artist_fanart_path,
|
|
||||||
a.artist_art_source, a.artist_art_sources_version
|
|
||||||
FROM artists a
|
|
||||||
WHERE a.id = $1
|
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetArtistByIDRow struct {
|
// Lookup an artist row by its UUID. Returns the full row; consumers
|
||||||
ID pgtype.UUID
|
// pick the columns they need.
|
||||||
Name string
|
func (q *Queries) GetArtistByID(ctx context.Context, id pgtype.UUID) (Artist, error) {
|
||||||
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) {
|
|
||||||
row := q.db.QueryRow(ctx, getArtistByID, id)
|
row := q.db.QueryRow(ctx, getArtistByID, id)
|
||||||
var i GetArtistByIDRow
|
var i Artist
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Name,
|
&i.Name,
|
||||||
&i.SortName,
|
&i.SortName,
|
||||||
&i.Mbid,
|
&i.Mbid,
|
||||||
|
&i.CreatedAt,
|
||||||
|
&i.UpdatedAt,
|
||||||
&i.ArtistThumbPath,
|
&i.ArtistThumbPath,
|
||||||
&i.ArtistFanartPath,
|
&i.ArtistFanartPath,
|
||||||
&i.ArtistArtSource,
|
&i.ArtistArtSource,
|
||||||
|
|||||||
@@ -11,15 +11,9 @@ DO UPDATE SET
|
|||||||
RETURNING *;
|
RETURNING *;
|
||||||
|
|
||||||
-- name: GetArtistByID :one
|
-- name: GetArtistByID :one
|
||||||
-- M7 cover-sources: enricher reads the artist's mbid + current art
|
-- Lookup an artist row by its UUID. Returns the full row; consumers
|
||||||
-- columns to drive eligibility check. (Modified from SELECT * to
|
-- pick the columns they need.
|
||||||
-- explicitly include the new artist_art_* columns added in migration
|
SELECT * FROM artists WHERE id = $1;
|
||||||
-- 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;
|
|
||||||
|
|
||||||
-- name: GetArtistByName :one
|
-- name: GetArtistByName :one
|
||||||
SELECT * FROM artists WHERE name = $1 LIMIT 1;
|
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.Bytes = [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
|
||||||
bogus.Valid = true
|
bogus.Valid = true
|
||||||
|
|
||||||
svc := NewService(pool, nil, nil)
|
svc := NewService(pool, nil, nil, "")
|
||||||
_, _, _, err := svc.RemoveTrack(context.Background(), bogus, admin.ID, false)
|
_, _, _, err := svc.RemoveTrack(context.Background(), bogus, admin.ID, false)
|
||||||
if !errors.Is(err, ErrNotFound) {
|
if !errors.Is(err, ErrNotFound) {
|
||||||
t.Errorf("err = %v, want ErrNotFound", err)
|
t.Errorf("err = %v, want ErrNotFound", err)
|
||||||
@@ -142,7 +142,7 @@ func TestRemoveTrack_LocalFile_HappyPath(t *testing.T) {
|
|||||||
_, _, track := seedArtistAlbumTrack(t, pool, "Solo", "", path)
|
_, _, track := seedArtistAlbumTrack(t, pool, "Solo", "", path)
|
||||||
|
|
||||||
fake := &fakeLidarrUnmonitorer{}
|
fake := &fakeLidarrUnmonitorer{}
|
||||||
svc := NewService(pool, nil, fake)
|
svc := NewService(pool, nil, fake, "")
|
||||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -170,7 +170,7 @@ func TestRemoveTrack_FileAlreadyMissing(t *testing.T) {
|
|||||||
missing := filepath.Join(t.TempDir(), "does-not-exist.mp3")
|
missing := filepath.Join(t.TempDir(), "does-not-exist.mp3")
|
||||||
_, _, track := seedArtistAlbumTrack(t, pool, "Ghost", "", missing)
|
_, _, 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)
|
_, _, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -226,7 +226,7 @@ func TestRemoveTrack_Cascade_AlbumEmpty(t *testing.T) {
|
|||||||
t.Fatalf("trackB: %v", err)
|
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)
|
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), trackA.ID, admin.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -259,7 +259,7 @@ func TestRemoveTrack_Cascade_ArtistEmpty(t *testing.T) {
|
|||||||
}
|
}
|
||||||
artist, album, track := seedArtistAlbumTrack(t, pool, "Lone", "", path)
|
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)
|
delAlbum, delArtist, _, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -325,7 +325,7 @@ func TestRemoveTrack_Unmonitor_HappyPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fake := &fakeLidarrUnmonitorer{}
|
fake := &fakeLidarrUnmonitorer{}
|
||||||
svc := NewService(pool, nil, fake)
|
svc := NewService(pool, nil, fake, "")
|
||||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -381,7 +381,7 @@ func TestRemoveTrack_Unmonitor_LidarrErrorIsNonFatal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fake := &fakeLidarrUnmonitorer{err: errors.New("simulated lidarr 5xx")}
|
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)
|
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v (want nil — Lidarr failure is non-fatal)", err)
|
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)
|
_, _, track := seedArtistAlbumTrack(t, pool, "Local", "", path)
|
||||||
|
|
||||||
fake := &fakeLidarrUnmonitorer{}
|
fake := &fakeLidarrUnmonitorer{}
|
||||||
svc := NewService(pool, nil, fake)
|
svc := NewService(pool, nil, fake, "")
|
||||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
@@ -437,7 +437,7 @@ func TestRemoveTrack_NoUnmonitor_SkipsLidarr(t *testing.T) {
|
|||||||
_, _, track := seedArtistAlbumTrack(t, pool, "NoMon", "track-mbid", path)
|
_, _, track := seedArtistAlbumTrack(t, pool, "NoMon", "track-mbid", path)
|
||||||
|
|
||||||
fake := &fakeLidarrUnmonitorer{}
|
fake := &fakeLidarrUnmonitorer{}
|
||||||
svc := NewService(pool, nil, fake)
|
svc := NewService(pool, nil, fake, "")
|
||||||
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
_, _, lidarrFailed, err := svc.RemoveTrack(context.Background(), track.ID, admin.ID, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("RemoveTrack: %v", err)
|
t.Fatalf("RemoveTrack: %v", err)
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ describe('/admin/integrations — cover art providers', () => {
|
|||||||
});
|
});
|
||||||
// coverage invalidation should NOT have been called
|
// coverage invalidation should NOT have been called
|
||||||
const coverageCalls = invalidateQueries.mock.calls.filter(
|
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);
|
expect(coverageCalls.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user