|
|
|
|
@@ -15,6 +15,10 @@ func TestApplyTypeToggles(t *testing.T) {
|
|
|
|
|
{RGID: "r4", Type: "Album", SecondaryTypes: []string{"Compilation"}},
|
|
|
|
|
{RGID: "r5", Type: "EP", SecondaryTypes: []string{}},
|
|
|
|
|
{RGID: "r6", Type: "Album", SecondaryTypes: []string{"EP"}},
|
|
|
|
|
{RGID: "r7", Type: "Live", SecondaryTypes: []string{}},
|
|
|
|
|
{RGID: "r8", Type: "Album", SecondaryTypes: []string{"Live"}},
|
|
|
|
|
{RGID: "r9", Type: "Remix", SecondaryTypes: []string{}},
|
|
|
|
|
{RGID: "r10", Type: "Album", SecondaryTypes: []string{"Remix"}},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
@@ -25,25 +29,57 @@ func TestApplyTypeToggles(t *testing.T) {
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "No filters",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false},
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 10,
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore singles only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
// Actually: r1(Single), r2(Album+Single), r5(EP), r6(Album+EP) should be filtered out
|
|
|
|
|
// Leaving: r3(Compilation), r4(Album+Compilation), r7(Live), r8(Album+Live), r9(Remix), r10(Album+Remix)
|
|
|
|
|
expectedCounts: 6,
|
|
|
|
|
expectedRGIDs: []string{"r3", "r4", "r7", "r8", "r9", "r10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore compilations only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: true, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
// r1, r2, r5, r6, r7, r8, r9, r10 (r3 and r4 filtered out)
|
|
|
|
|
expectedCounts: 8,
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r5", "r6", "r7", "r8", "r9", "r10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore live only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: true, IgnoreRemix: false},
|
|
|
|
|
// r1, r2, r3, r4, r5, r6, r9, r10 (r7 and r8 filtered out)
|
|
|
|
|
expectedCounts: 8,
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r3", "r4", "r5", "r6", "r9", "r10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore remix only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: true},
|
|
|
|
|
// r1, r2, r3, r4, r5, r6, r7, r8 (r9 and r10 filtered out)
|
|
|
|
|
expectedCounts: 8,
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore both singles and compilations",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
// Actually: r1, r2, r5, r6 filtered (singles) and r3, r4 filtered (compilations)
|
|
|
|
|
// Leaving: r7(Live), r8(Album+Live), r9(Remix), r10(Album+Remix)
|
|
|
|
|
expectedCounts: 4,
|
|
|
|
|
expectedRGIDs: []string{"r7", "r8", "r9", "r10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore live and remix",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: true, IgnoreRemix: true},
|
|
|
|
|
// r1, r2, r3, r4, r5, r6 (r7, r8, r9, r10 filtered out)
|
|
|
|
|
expectedCounts: 6,
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r3", "r4", "r5", "r6"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore singles only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: false},
|
|
|
|
|
expectedCounts: 2, // r3, r4
|
|
|
|
|
expectedRGIDs: []string{"r3", "r4"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore compilations only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: true},
|
|
|
|
|
expectedCounts: 4, // r1, r2, r5, r6
|
|
|
|
|
expectedRGIDs: []string{"r1", "r2", "r5", "r6"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore both",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true},
|
|
|
|
|
name: "Ignore all four types",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true, IgnoreLive: true, IgnoreRemix: true},
|
|
|
|
|
expectedCounts: 0,
|
|
|
|
|
expectedRGIDs: []string{},
|
|
|
|
|
},
|
|
|
|
|
@@ -72,6 +108,10 @@ func TestApplyTypeTogglesToReleaseGroups(t *testing.T) {
|
|
|
|
|
{ID: "g4", Type: "Album", SecondaryTypes: []string{"Compilation"}},
|
|
|
|
|
{ID: "g5", Type: "EP", SecondaryTypes: []string{}},
|
|
|
|
|
{ID: "g6", Type: "Album", SecondaryTypes: []string{"EP"}},
|
|
|
|
|
{ID: "g7", Type: "Live", SecondaryTypes: []string{}},
|
|
|
|
|
{ID: "g8", Type: "Album", SecondaryTypes: []string{"Live"}},
|
|
|
|
|
{ID: "g9", Type: "Remix", SecondaryTypes: []string{}},
|
|
|
|
|
{ID: "g10", Type: "Album", SecondaryTypes: []string{"Remix"}},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
@@ -82,25 +122,49 @@ func TestApplyTypeTogglesToReleaseGroups(t *testing.T) {
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "No filters",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false},
|
|
|
|
|
expectedCounts: 6,
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g3", "g4", "g5", "g6"},
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 10,
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8", "g9", "g10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore singles only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: false},
|
|
|
|
|
expectedCounts: 2, // g3, g4
|
|
|
|
|
expectedIDs: []string{"g3", "g4"},
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 6,
|
|
|
|
|
expectedIDs: []string{"g3", "g4", "g7", "g8", "g9", "g10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore compilations only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: true},
|
|
|
|
|
expectedCounts: 4, // g1, g2, g5, g6
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g5", "g6"},
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: true, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 8, // g1, g2, g5, g6, g7, g8, g9, g10 (g3 and g4 filtered out)
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g5", "g6", "g7", "g8", "g9", "g10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore both",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true},
|
|
|
|
|
name: "Ignore live only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: true, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 8, // g1, g2, g3, g4, g5, g6, g9, g10 (g7 and g8 filtered out)
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g3", "g4", "g5", "g6", "g9", "g10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore remix only",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: false, IgnoreRemix: true},
|
|
|
|
|
expectedCounts: 8, // g1, g2, g3, g4, g5, g6, g7, g8 (g9 and g10 filtered out)
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g3", "g4", "g5", "g6", "g7", "g8"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore both singles and compilations",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true, IgnoreLive: false, IgnoreRemix: false},
|
|
|
|
|
expectedCounts: 4,
|
|
|
|
|
expectedIDs: []string{"g7", "g8", "g9", "g10"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore live and remix",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: false, IgnoreCompilations: false, IgnoreLive: true, IgnoreRemix: true},
|
|
|
|
|
expectedCounts: 6, // g1, g2, g3, g4, g5, g6 (g7, g8, g9, g10 filtered out)
|
|
|
|
|
expectedIDs: []string{"g1", "g2", "g3", "g4", "g5", "g6"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Ignore all four types",
|
|
|
|
|
opts: musicbrainz.FilterOptions{IgnoreSingles: true, IgnoreCompilations: true, IgnoreLive: true, IgnoreRemix: true},
|
|
|
|
|
expectedCounts: 0,
|
|
|
|
|
expectedIDs: []string{},
|
|
|
|
|
},
|
|
|
|
|
|