refactor: use diff for test results and add cases
This commit is contained in:
parent
f0ec6d4519
commit
16e4dce253
5
go.mod
5
go.mod
@ -1,3 +1,8 @@
|
|||||||
module git.javil.eu/jacob1123/dl-rename
|
module git.javil.eu/jacob1123/dl-rename
|
||||||
|
|
||||||
go 1.22.9
|
go 1.22.9
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 // indirect
|
||||||
|
github.com/sergi/go-diff v1.3.1 // indirect
|
||||||
|
)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/andreyvit/diff"
|
||||||
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func Test(t *testing.T) {
|
||||||
m := newMediaElement("Misfits - S02E03 - EN FORCED")
|
m := newMediaElement("Misfits - S02E03 - EN FORCED")
|
||||||
@ -13,12 +17,15 @@ func Test(t *testing.T) {
|
|||||||
func TestExamples(t *testing.T) {
|
func TestExamples(t *testing.T) {
|
||||||
// list of strings with expected output
|
// list of strings with expected output
|
||||||
examples := [][]string{
|
examples := [][]string{
|
||||||
{"Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR.mkv", "Speak No Evil (2024) DE 1080P X265.mkv"},
|
{"Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR.nfo", "Speak No Evil (2024) DE 1080p x265.nfo"},
|
||||||
|
{"Speak.No.Evil.2024.German.EAC3.DL.1080p.BluRay.x265-VECTOR/Speak.No.Evil.2024.nfo", "Speak No Evil (2024) DE 1080p x265.nfo"},
|
||||||
|
{"Speak.No.Evil.2024.nfo", "Speak No Evil (2024).nfo"},
|
||||||
|
{"Miracles.from.Heaven.2016.1080p.BluRay.X264-AMIABLE/Miracles.from.Heaven.2016.1080p.BluRay.X264-AMIABLE.mkv", "Miracles from Heaven (2016) 1080p x264.mkv"},
|
||||||
}
|
}
|
||||||
for _, example := range examples {
|
for _, example := range examples {
|
||||||
element := newMediaElement(example[0])
|
element := newMediaElement(example[0])
|
||||||
if expected, got := example[1], element.Path(); expected != got {
|
if expected, got := example[1], element.Path(); expected != got {
|
||||||
t.Errorf("Expected %s, got %s", expected, got)
|
t.Errorf("Result not expected for %s:\n%v", example[0], diff.LineDiff(expected, got))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user