-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_test.go
57 lines (51 loc) · 1.45 KB
/
job_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
package qpm
import "testing"
func TestQPM_job_shell(t *testing.T) {
t.Parallel()
type want struct {
shell string
ok bool
}
tests := map[string]struct {
shell map[string]struct{}
arg []string
want want
}{
"argが空の場合、無効": {
map[string]struct{}{"zsh": {}}, []string{}, want{"", false},
},
"shellが空の場合、無効": {
map[string]struct{}{}, []string{"zsh"}, want{"", false},
},
"argがshellに存在しない場合、無効": {
map[string]struct{}{"zsh": {}}, []string{"bash"}, want{"", false},
},
"argがshellに存在する場合、有効": {
map[string]struct{}{"zsh": {}}, []string{"zsh"}, want{"zsh", true},
},
"有効なshellが複数ある場合、優先度の高いものが返る1": {
map[string]struct{}{"zsh": {}, "bash": {}}, []string{"zsh", "bash"}, want{"zsh", true},
},
"有効なshellが複数ある場合、優先度の高いものが返る2": {
map[string]struct{}{"zsh": {}, "bash": {}}, []string{"bash", "zsh"}, want{"bash", true},
},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
t.Parallel()
j := job{
availableShell: tt.shell,
}
// Act
gotShell, gotOK := j.shell(tt.arg)
// Assert
if gotShell != tt.want.shell {
t.Errorf("job.AvailableShell() got = %v, want %v", gotShell, tt.want.shell)
}
if gotOK != tt.want.ok {
t.Errorf("job.AvailableShell() got1 = %v, want %v", gotOK, tt.want.ok)
}
})
}
}