args are OUTD IND {} patterns..

This commit is contained in:
bel
2025-04-04 22:28:38 -06:00
parent 81d1ce1dde
commit 805e666230
2 changed files with 46 additions and 36 deletions

View File

@@ -15,7 +15,7 @@ func TestRun(t *testing.T) {
cases := map[string]struct {
given []string
patterns []string
overrides map[string]string
overrides main.Fields
want []string
}{
"empty": {},
@@ -29,8 +29,8 @@ func TestRun(t *testing.T) {
".urvivor.[Aa][Uu].*[sS](?P<season>[0-9]+)[eE](?P<episode>[0-9]*).*1080.*MeGusta",
".urvivor.[Aa][Uu].*[sS](?P<season>[0-9]+)[eE](?P<episode>[0-9]*).*720.*MeGusta",
},
overrides: map[string]string{
"title": "Australian_Survivor",
overrides: main.Fields{
Title: "Australian_Survivor",
},
want: []string{
"Australian_Survivor_S12E11.mkv",
@@ -45,8 +45,8 @@ func TestRun(t *testing.T) {
patterns: []string{
`^\[[^\]]*\] (?P<title>.*) - (?<episode>[0-9]*)`,
},
overrides: map[string]string{
"season": "01",
overrides: main.Fields{
Season: "01",
},
want: []string{
"Tokidoki_Bosotto_Russia-go_de_Dereru_Tonari_no_Alya-san_S01E01.mkv",
@@ -65,7 +65,9 @@ func TestRun(t *testing.T) {
outd := t.TempDir()
if err := main.Run(context.Background(), outd, ind, c.patterns, c.overrides); err != nil {
t.Fatal(err)
t.Fatal("err on first run:", err)
} else if err := main.Run(context.Background(), outd, ind, c.patterns, c.overrides); err != nil {
t.Fatal("err on second run:", err)
}
for _, f := range c.want {
@@ -84,20 +86,8 @@ func TestRun(t *testing.T) {
if !slices.Contains(c.want, path.Base(entry.Name())) {
t.Errorf("unexpected %s", entry.Name())
}
if stat, err := entry.Info(); err != nil {
t.Errorf("cant read info of %s: %v", entry.Name(), err)
} else if !stat.Mode().IsRegular() {
t.Errorf("non-regular file %s in out: %v", entry.Name(), stat.Mode())
}
}
}
if entries, err := os.ReadDir(outd); err != nil {
t.Error("failed to list outdir: %w", err)
} else {
for _, entry := range entries {
if !slices.Contains(c.want, path.Base(entry.Name())) {
t.Errorf("unexpected %s", entry.Name())
if !entry.Type().IsRegular() {
t.Errorf("non-regular file %s in out: %v", entry.Name(), entry.Type())
}
}
}