-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathutils_test.go
46 lines (42 loc) · 985 Bytes
/
utils_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
package utils
import (
"testing"
)
func TestParseScriptParams(t *testing.T) {
tests := []struct {
description string
input map[string]string
expectedOutput map[string]string
isValid bool
}{
{
"base-ok",
map[string]string{"script": "ls /"},
map[string]string{"script": "ls /"},
true,
},
{
"not-ok-nonexistant-file-specified-for-script",
map[string]string{"script": "@{/some/file/which/does/not/exist/and/thus/fails}"},
nil,
false,
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
output, err := ParseScriptParams(tt.input)
if tt.isValid && err != nil {
t.Errorf("failed on valid input")
}
if !tt.isValid && err == nil {
t.Errorf("did not fail on invalid input")
}
if !tt.isValid {
return
}
if output["script"] != tt.expectedOutput["script"] {
t.Errorf("expected output to be %s, got %s", tt.expectedOutput["script"], output["script"])
}
})
}
}