gobbler/categorize/tv/season_test.go

91 lines
1.8 KiB
Go

package tv
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetSeasonsForFile(t *testing.T) {
tt := []struct {
filename string
expectedSeason []int
expectedError error
}{
{
"The.Simpsons.S06E05.720p.DSNP.WEB-DL.DDP5.1.H.264-MZABI",
[]int{6},
nil,
},
{
"The.Simpsons.s06e05.720p.DSNP.WEB-DL.DDP5.1.H.264-MZABI",
[]int{6},
nil,
},
{
"The.Simpsons.S12.720p.DSNP.WEB-DL.DDP5.1.H.264-MZABI",
[]int{12},
nil,
},
{
"The.Amazing.Spider-Man.1977.S01.VHSRip",
[]int{1},
nil,
},
{
"The Amazing Spider-Man Season 2 (1977)",
[]int{2},
nil,
},
{
"The Amazing Spider-Man Season-----2 (1977)",
[]int{2},
nil,
},
{
// Note the S here. This would trigger a match if we didn't check for the same char
"The Amazing Spider-Man SomeTag (1977)",
[]int{2},
errNoSeasonInfo,
},
{
"The.Princess.Bride.1987.REMASTERED.1080p.BluRay.H264.AC3.DD5.1.Will1869",
[]int{0},
errNoSeasonInfo,
},
{
"Seinfeld S01-09 WEB hevc-d3g",
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
nil,
},
{
"The.Office.US.S01-S09.1080p.WEB-DL.BluRay.DD5.1.DTS-Mixed",
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9},
nil,
},
{
"Arrested.Development.S01-S03.BDRip.x264-ARCHiViST [No RAR]",
[]int{1, 2, 3},
nil,
},
}
for _, test := range tt {
testName := fmt.Sprintf("%s to Season %d", test.filename, test.expectedSeason)
if test.expectedError != nil {
testName = fmt.Sprintf("%s has no season", test.filename)
}
t.Run(testName, func(t *testing.T) {
season, err := GetSeasonsForFile(test.filename)
if test.expectedError != nil {
assert.ErrorIs(t, err, test.expectedError)
} else {
assert.Nil(t, err)
assert.Equal(t, test.expectedSeason, season)
}
})
}
}