musicbrainz-provider #2
@@ -76,9 +76,9 @@ Problem: Three separate filter implementations (`musicbrainz.FilterReleaseGroups
|
|||||||
- [x] Run tests - must pass before task 7
|
- [x] Run tests - must pass before task 7
|
||||||
|
|
||||||
### Task 7: Handle ErrArtistNotFound in ScanArtist gracefully
|
### Task 7: Handle ErrArtistNotFound in ScanArtist gracefully
|
||||||
- [ ] In `ScanArtist`, wrap `GetArtistSettings` call; if `ErrArtistNotFound`, use empty `TypeFilter` (no filtering) instead of returning error
|
- [x] In `ScanArtist`, wrap `GetArtistSettings` call; if `ErrArtistNotFound`, use empty `TypeFilter` (no filtering) instead of returning error
|
||||||
- [ ] Write test: create external_releases row for non-existent artist_id, verify ScanArtist succeeds and returns missing releases (with default no-filter behavior)
|
- [x] Write test: create external_releases row for non-existent artist_id, verify ScanArtist succeeds and returns missing releases (with default no-filter behavior)
|
||||||
- [ ] Run tests - must pass before task 8
|
- [x] Run tests - must pass before task 8
|
||||||
|
|
||||||
### Task 8: Fix NotifyOnce map key to use composite ArtistID+RGID
|
### Task 8: Fix NotifyOnce map key to use composite ArtistID+RGID
|
||||||
- [ ] Change `missingByRGID` map key from `m.RGID` to `m.ArtistID + "|" + m.RGID` (or use a struct key)
|
- [ ] Change `missingByRGID` map key from `m.RGID` to `m.ArtistID + "|" + m.RGID` (or use a struct key)
|
||||||
|
|||||||
@@ -247,6 +247,46 @@ func seedArtistUnmonitored(t *testing.T, db *database.DB, id, name string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestScanArtist_ErrArtistNotFound verifies that ScanArtist handles ErrArtistNotFound
|
||||||
|
// by using empty TypeFilter (no filtering) instead of returning an error.
|
||||||
|
func TestScanArtist_ErrArtistNotFound(t *testing.T) {
|
||||||
|
db := newTestDB(t)
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
// Disable foreign key constraints to allow inserting external_releases without artist_settings
|
||||||
|
if _, err := db.Conn().Exec("PRAGMA foreign_keys = OFF"); err != nil {
|
||||||
|
t.Fatalf("disable foreign keys: %v", err)
|
||||||
|
}
|
||||||
|
// Re-enable foreign keys when we're done
|
||||||
|
defer func() {
|
||||||
|
if _, err := db.Conn().Exec("PRAGMA foreign_keys = ON"); err != nil {
|
||||||
|
t.Fatalf("re-enable foreign keys: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Don't create artist settings - this will cause GetArtistSettings to return ErrArtistNotFound
|
||||||
|
// Insert external release directly to bypass FK constraint for testing inconsistent state
|
||||||
|
if _, err := db.Conn().Exec(
|
||||||
|
"INSERT INTO external_releases (rgid, artist_id, title, type, release_date, is_ignored) VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
|
"rg1", "nonexistent-artist", "Test Album", "Album", "", false,
|
||||||
|
); err != nil {
|
||||||
|
t.Fatalf("insert external release: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
missing, err := ScanArtist(context.Background(), db, "nonexistent-artist", 0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ScanArtist() error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should return the release as missing (no filtering applied)
|
||||||
|
if len(missing) != 1 {
|
||||||
|
t.Errorf("expected 1 missing release, got %d", len(missing))
|
||||||
|
}
|
||||||
|
if missing[0].RGID != "rg1" {
|
||||||
|
t.Errorf("expected rg1 to be missing, got %v", missing[0].RGID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestScanArtist_TypeToggle verifies that ScanArtist honors the artist's
|
// TestScanArtist_TypeToggle verifies that ScanArtist honors the artist's
|
||||||
// ignore_singles / ignore_compilations toggles at read time, so a toggled
|
// ignore_singles / ignore_compilations toggles at read time, so a toggled
|
||||||
// artist stops reporting those categories as missing immediately (without
|
// artist stops reporting those categories as missing immediately (without
|
||||||
|
|||||||
Reference in New Issue
Block a user