fix: address code review findings
This commit is contained in:
@@ -19,8 +19,12 @@ func mbReleaseGroupXML(id, title, rgType, status, artistID, artistName, releaseD
|
||||
if status != "" {
|
||||
statusAttr = ` status="` + status + `"`
|
||||
}
|
||||
// Release groups carry type via <primary-type>; the legacy "type" attribute
|
||||
// is also emitted (ignored by the parser) for realism. Status has no meaning
|
||||
// for release groups and is not parsed.
|
||||
return `<release-group id="` + id + `" type="` + rgType + `"` + statusAttr + `>` +
|
||||
`<title>` + title + `</title>` +
|
||||
`<primary-type>` + rgType + `</primary-type>` +
|
||||
`<artist-credit><name-credit><artist id="` + artistID + `">` +
|
||||
`<name>` + artistName + `</name>` +
|
||||
`</artist></name-credit></artist-credit>` +
|
||||
@@ -200,13 +204,14 @@ func TestSyncArtistDiscography_CacheHit_ReturnsCached(t *testing.T) {
|
||||
// Test: SyncArtistDiscography applies filtering (excluded statuses)
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
func TestSyncArtistDiscography_FiltersExcludedStatuses(t *testing.T) {
|
||||
func TestSyncArtistDiscography_StatusIsNotFiltered(t *testing.T) {
|
||||
artistMBID := "cccccccc-dddd-eeee-ffff-000000000000"
|
||||
artistID := "nav-cccccccc"
|
||||
|
||||
server := newTestMBServer(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/xml")
|
||||
// Include a Bootleg and a Promotion that should be filtered out.
|
||||
// These all carry status values, but release groups have no status in
|
||||
// ws/2, so none should be filtered on that basis.
|
||||
resp := mbReleaseGroupListResponse(
|
||||
mbReleaseGroupXML("rg-legit", "Legit Album", "Album", "", artistMBID, "Artist", "2020-01-01")+
|
||||
mbReleaseGroupXML("rg-bootleg", "Bootleg Album", "Album", "Bootleg", artistMBID, "Artist", "2020-02-01")+
|
||||
@@ -231,12 +236,9 @@ func TestSyncArtistDiscography_FiltersExcludedStatuses(t *testing.T) {
|
||||
t.Fatalf("SyncArtistDiscography() error: %v", err)
|
||||
}
|
||||
|
||||
// Only the legit album should remain after filtering.
|
||||
if len(releases) != 1 {
|
||||
t.Fatalf("expected 1 release after filtering, got %d", len(releases))
|
||||
}
|
||||
if releases[0].RGID != "rg-legit" {
|
||||
t.Errorf("expected RGID 'rg-legit', got %q", releases[0].RGID)
|
||||
// All four are Albums; status is not a filter, so all four are kept.
|
||||
if len(releases) != 4 {
|
||||
t.Fatalf("expected 4 releases (status is not filtered), got %d", len(releases))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,9 +277,10 @@ func TestSyncArtistDiscography_FiltersExcludedTypes(t *testing.T) {
|
||||
t.Fatalf("SyncArtistDiscography() error: %v", err)
|
||||
}
|
||||
|
||||
// Soundtrack should be excluded (not in includedTypes).
|
||||
if len(releases) != 4 {
|
||||
t.Fatalf("expected 4 releases after type filtering, got %d", len(releases))
|
||||
// Soundtrack and the bare "Compilation" primary type should be excluded
|
||||
// (Compilation is not a primary type; it is classified via secondary type).
|
||||
if len(releases) != 3 {
|
||||
t.Fatalf("expected 3 releases after type filtering, got %d", len(releases))
|
||||
}
|
||||
|
||||
rgIDs := make(map[string]bool)
|
||||
@@ -287,6 +290,9 @@ func TestSyncArtistDiscography_FiltersExcludedTypes(t *testing.T) {
|
||||
if rgIDs["rg-soundtrack"] {
|
||||
t.Error("Soundtrack type should have been filtered out")
|
||||
}
|
||||
if rgIDs["rg-comp"] {
|
||||
t.Error("Compilation primary type should have been filtered out")
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user