-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec_test.go
60 lines (52 loc) · 908 Bytes
/
exec_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
package exec
import (
"reflect"
"testing"
)
type testStruct struct {
FirstParam string
SecondParam string
ThirdParam bool
FourthParam bool
FifthParam int
SixthParam string
ZeventhParam int
}
func TestBuildArgs(t *testing.T) {
tstrct := testStruct{
FirstParam: "val1",
SecondParam: "val2",
ThirdParam: true,
FourthParam: false,
FifthParam: 8,
}
got := BuildArgs(
"command1",
"--opt1",
567,
tstrct,
[]string{"param1", "param2"},
[]int{7465, 23},
)
want := []string{
"command1",
"--opt1",
"567",
"--first-param", "val1",
"--second-param", "val2",
"--third-param",
"--fifth-param", "8",
"param1",
"param2",
"7465",
"23",
}
for i := 0; i < len(got); i++ {
if got[i] != want[i] {
t.Errorf("\ngot: %v\nwant: %v\n", got[i], want[i])
}
}
if !reflect.DeepEqual(got, want) {
t.Errorf("\ngot: %v\nwant: %v\n", got, want)
}
}