package tracks import ( "testing" "git.fabledsword.com/bvandeusen/minstrel/internal/library" ) func mbids(track, album string) library.MergedCopy { c := library.MergedCopy{} if track != "" { c.TrackMbid = &track } if album != "" { c.AlbumMbid = &album } return c } // Unmonitoring a second file of the kept copy's own album track would stop // Lidarr managing the kept file too; that case must be recognised. func TestSameLidarrTrack(t *testing.T) { for _, tc := range []struct { name string kept library.MergedCopy removed library.MergedCopy wantSame bool }{ {"same recording on the same album", mbids("rec", "alb"), mbids("rec", "alb"), true}, {"same recording on a compilation", mbids("rec", "alb"), mbids("rec", "comp"), false}, {"different recordings on one album", mbids("rec", "alb"), mbids("rec-2", "alb"), false}, {"kept copy has no mbids", mbids("", ""), mbids("rec", "alb"), false}, {"removed copy has no album mbid", mbids("rec", "alb"), mbids("rec", ""), false}, } { if got := sameLidarrTrack(tc.kept, tc.removed); got != tc.wantSame { t.Errorf("%s: sameLidarrTrack = %v, want %v", tc.name, got, tc.wantSame) } } }