94 lines
2.3 KiB
Go
94 lines
2.3 KiB
Go
package scanner
|
|
|
|
import "testing"
|
|
|
|
func TestParseMovie(t *testing.T) {
|
|
p := parseMovie("The.Matrix.1999.2160p.UHD.BluRay.REMUX.HEVC.TrueHD.Atmos")
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["title"] != "The Matrix" {
|
|
t.Fatalf("title=%v", p["title"])
|
|
}
|
|
if p["year"] != 1999 {
|
|
t.Fatalf("year=%v", p["year"])
|
|
}
|
|
if p["resolution"] != "2160p" {
|
|
t.Fatalf("resolution=%v", p["resolution"])
|
|
}
|
|
}
|
|
|
|
func TestParseMovieUHDOnly(t *testing.T) {
|
|
p := parseMovie("Avatar.UHD.BluRay.mkv")
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["resolution"] != "2160p" {
|
|
t.Fatalf("resolution=%v", p["resolution"])
|
|
}
|
|
}
|
|
|
|
func TestParseMovieParenFolder(t *testing.T) {
|
|
p := parseMovieFromPath(`/media/movies/Inception (2010)/Inception.mkv`)
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["title"] != "Inception" {
|
|
t.Fatalf("title=%v", p["title"])
|
|
}
|
|
if p["year"] != 2010 {
|
|
t.Fatalf("year=%v", p["year"])
|
|
}
|
|
}
|
|
|
|
func TestParseSeries(t *testing.T) {
|
|
p := parseSeries("Breaking.Bad.S03E04.1080p.BluRay")
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["title"] != "Breaking Bad" {
|
|
t.Fatalf("title=%v", p["title"])
|
|
}
|
|
if p["season"] != 3 || p["episode"] != 4 {
|
|
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
|
|
}
|
|
}
|
|
|
|
func TestParseSeriesAlt(t *testing.T) {
|
|
p := parseSeries("Show.Name.1x02.720p")
|
|
if p == nil || p["season"] != 1 || p["episode"] != 2 {
|
|
t.Fatalf("unexpected: %#v", p)
|
|
}
|
|
}
|
|
|
|
func TestParseSeriesSeasonFolder(t *testing.T) {
|
|
p := parseSeriesFromPath(`/media/series/Breaking Bad/Season 01/Breaking.Bad.S01E01.mkv`)
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["title"] != "Breaking Bad" {
|
|
t.Fatalf("title=%v", p["title"])
|
|
}
|
|
if p["season"] != 1 || p["episode"] != 1 {
|
|
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
|
|
}
|
|
}
|
|
|
|
func TestParseSeriesSeasonFolderEpisodeOnly(t *testing.T) {
|
|
p := parseSeriesFromPath(`/media/series/The Office/Season 2/E05 - Episode.mkv`)
|
|
if p == nil {
|
|
t.Fatal("expected parse result")
|
|
}
|
|
if p["title"] != "The Office" {
|
|
t.Fatalf("title=%v", p["title"])
|
|
}
|
|
if p["season"] != 2 || p["episode"] != 5 {
|
|
t.Fatalf("season/episode=%v/%v", p["season"], p["episode"])
|
|
}
|
|
}
|
|
|
|
func TestSkipSample(t *testing.T) {
|
|
if parseMovieFromPath(`/media/movies/Foo (2020)/Foo-sample.mkv`) != nil {
|
|
t.Fatal("sample should be skipped")
|
|
}
|
|
}
|