tests clear
parent
dc8c9fdf0c
commit
caef12deb8
3
main.go
3
main.go
|
|
@ -95,6 +95,9 @@ func foundOne(ctx context.Context, outd, inf string, fields Fields, mvNLn MvNLn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RealMvNLn(outf, inf string) error {
|
func RealMvNLn(outf, inf string) error {
|
||||||
|
if stat, err := os.Stat(inf); err != nil || !stat.Mode().IsRegular() {
|
||||||
|
return fmt.Errorf("cannot mv_n_ln(%s): (%v) mode=%v", inf, err, stat.Mode())
|
||||||
|
}
|
||||||
if _, err := os.Stat(outf); err == nil {
|
if _, err := os.Stat(outf); err == nil {
|
||||||
return nil // fmt.Errorf("conflict: %s already exists", path.Base(outf))
|
return nil // fmt.Errorf("conflict: %s already exists", path.Base(outf))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
main_test.go
42
main_test.go
|
|
@ -11,6 +11,48 @@ import (
|
||||||
main "gitea/show-ingestion"
|
main "gitea/show-ingestion"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestRunChoosesOne(t *testing.T) {
|
||||||
|
ind := t.TempDir()
|
||||||
|
outd := t.TempDir()
|
||||||
|
|
||||||
|
for _, given := range []string{
|
||||||
|
"Survivor.AU.S12E11.1080p.HEVC.x265-MeGusta[EZTVx.to].mkv",
|
||||||
|
"Survivor.AU.S12E11.720p.HEVC.x265-MeGusta[EZTVx.to].mkv",
|
||||||
|
"Survivor.AU.S12E12.720p.HEVC.x265-MeGusta[EZTVx.to].mkv",
|
||||||
|
} {
|
||||||
|
ioutil.WriteFile(path.Join(ind, given), []byte{}, os.ModePerm)
|
||||||
|
}
|
||||||
|
|
||||||
|
want := map[string]bool{
|
||||||
|
"Australian_Survivor_S12E11.mkv": false,
|
||||||
|
"Australian_Survivor_S12E12.mkv": false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := main.Run(context.Background(),
|
||||||
|
outd,
|
||||||
|
ind,
|
||||||
|
[]string{
|
||||||
|
".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",
|
||||||
|
},
|
||||||
|
main.Fields{
|
||||||
|
Title: "Australian_Survivor",
|
||||||
|
},
|
||||||
|
func(outf, inf string) error {
|
||||||
|
want[path.Base(outf)] = true
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range want {
|
||||||
|
if !v {
|
||||||
|
t.Errorf("did not mv_n_ln(outf=%s)", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRun(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
given []string
|
given []string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue