96 lines
2.5 KiB
Go
96 lines
2.5 KiB
Go
package matcher
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAlbumMatchScore(t *testing.T) {
|
|
tests := []struct {
|
|
album string
|
|
torrent string
|
|
artist string
|
|
wantMin float64
|
|
wantMax float64
|
|
match bool
|
|
}{
|
|
{
|
|
album: "Ain't My Bitch",
|
|
torrent: "Metallica - Ain't My Bitch (2025) [FLAC]",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "Ain't My Bitch",
|
|
torrent: "Metallica - Aint My Bitch Remastered 2025 FLAC",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "72 Seasons",
|
|
torrent: "Metallica - 72 Seasons (2023) [24Bit-48kHz] FLAC [PMEDIA] ⭐️",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "Kill 'Em All",
|
|
torrent: "Metallica - Kill Em All [1983] FLAC",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "...And Justice for All",
|
|
torrent: "Metallica - And Justice For All (Remastered) FLAC",
|
|
artist: "Metallica",
|
|
wantMin: 0.7, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "Master of Puppets",
|
|
torrent: "Metallica - Master of Puppets (Remastered Deluxe Box Set) FLAC",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "Ain't My Bitch",
|
|
torrent: "Metallica - Load 1996 (Japan SHM-CD)",
|
|
artist: "Metallica",
|
|
wantMin: 0.0, wantMax: 0.3, match: false,
|
|
},
|
|
{
|
|
album: "Ain't My Bitch",
|
|
torrent: "Metallica - The Memory Remains (Singles, 2026 remastered)",
|
|
artist: "Metallica",
|
|
wantMin: 0.0, wantMax: 0.3, match: false,
|
|
},
|
|
{
|
|
album: "Ain't My Bitch",
|
|
torrent: "Metallica - 72 Seasons (2023) [24Bit-48kHz] FLAC",
|
|
artist: "Metallica",
|
|
wantMin: 0.0, wantMax: 0.3, match: false,
|
|
},
|
|
{
|
|
album: "Hardwired...to Self-Destruct",
|
|
torrent: "Metallica - Hardwired To Self-Destruct (Deluxe 2016) [FLAC]",
|
|
artist: "Metallica",
|
|
wantMin: 0.7, wantMax: 1.0, match: true,
|
|
},
|
|
{
|
|
album: "S&M",
|
|
torrent: "Metallica - S&M (1999) [FLAC]",
|
|
artist: "Metallica",
|
|
wantMin: 0.9, wantMax: 1.0, match: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.album+" vs "+tt.torrent, func(t *testing.T) {
|
|
score := AlbumMatchScore(tt.album, tt.torrent, tt.artist)
|
|
assert.GreaterOrEqual(t, score, tt.wantMin, "score too low: %.2f", score)
|
|
assert.LessOrEqual(t, score, tt.wantMax, "score too high: %.2f", score)
|
|
assert.Equal(t, tt.match, IsAlbumMatch(tt.album, tt.torrent, tt.artist),
|
|
"match mismatch for score %.2f", score)
|
|
})
|
|
}
|
|
}
|