-
Notifications
You must be signed in to change notification settings - Fork 0
/
namegenerator_test.go
110 lines (94 loc) · 3.48 KB
/
namegenerator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package main
import "testing"
func TestFilenameGenerator(t *testing.T) {
generator := NewNameGenerator("/home/user/videos", 2, false)
pairs := []struct {
Title string
Season int
Episode int
Expected string
}{
{"The Big Bang Theory", 1, 2, "The Big Bang Theory s01e02"},
{"How I Met Your Mother", 10, 221, "How I Met Your Mother s10e221"}}
for _, pair := range pairs {
if gen := generator.GenerateFilename(pair.Title, pair.Season, pair.Episode, getExtension(pair.Expected)); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
generator = NewNameGenerator("/home/user/videos", 0, false)
pairs = []struct {
Title string
Season int
Episode int
Expected string
}{
{"The Big Bang Theory", 1, 2, "The Big Bang Theory s1e2"},
{"How I Met Your Mother", 10, 221, "How I Met Your Mother s10e221"}}
for _, pair := range pairs {
if gen := generator.GenerateFilename(pair.Title, pair.Season, pair.Episode, getExtension(pair.Expected)); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
}
func TestFilepathGenerator(t *testing.T) {
generator := NewNameGenerator("/home/user/videos", 2, false)
pairs := []struct {
Title string
Season int
Episode int
Expected string
}{
{"The Big Bang Theory", 1, 2, "/home/user/videos/The Big Bang Theory/S01/"},
{"How I Met Your Mother", 10, 221, "/home/user/videos/How I Met Your Mother/S10/"}}
for _, pair := range pairs {
if gen := generator.GenerateFilepath(pair.Title, pair.Season, pair.Episode); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
generator = NewNameGenerator("/home/user/videos", 0, false)
pairs = []struct {
Title string
Season int
Episode int
Expected string
}{
{"The Big Bang Theory", 1, 2, "/home/user/videos/The Big Bang Theory/S1/"},
{"How I Met Your Mother", 10, 221, "/home/user/videos/How I Met Your Mother/S10/"}}
for _, pair := range pairs {
if gen := generator.GenerateFilepath(pair.Title, pair.Season, pair.Episode); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
}
func TestLocationGenerator(t *testing.T) {
generator := NewNameGenerator("/home/user/videos", 2, false)
pairs := []struct {
Title string
Season int
Episode int
Extension string
Expected string
}{
{"The Big Bang Theory", 1, 2, ".mp4", "/home/user/videos/The Big Bang Theory/S01/The Big Bang Theory s01e02.mp4"},
{"How I Met Your Mother", 10, 221, ".avi", "/home/user/videos/How I Met Your Mother/S10/How I Met Your Mother s10e221.avi"}}
for _, pair := range pairs {
if gen := generator.GenerateLocation(pair.Title, pair.Season, pair.Episode, pair.Extension); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
generator = NewNameGenerator("/home/user/videos", 0, false)
pairs = []struct {
Title string
Season int
Episode int
Extension string
Expected string
}{
{"The Big Bang Theory", 1, 2, ".mp4", "/home/user/videos/The Big Bang Theory/S1/The Big Bang Theory s1e2.mp4"},
{"How I Met Your Mother", 10, 221, ".avi", "/home/user/videos/How I Met Your Mother/S10/How I Met Your Mother s10e221.avi"}}
for _, pair := range pairs {
if gen := generator.GenerateLocation(pair.Title, pair.Season, pair.Episode, pair.Extension); gen != pair.Expected {
t.Errorf("Name should be '%s'; '%s' returned", pair.Expected, gen)
}
}
}