@@ -18,6 +18,7 @@ func TestExecCommand_Run(t *testing.T) {
18
18
type fields struct {
19
19
params * chaos.GlobalParams
20
20
command string
21
+ args []string
21
22
limit int
22
23
}
23
24
type args struct {
@@ -38,7 +39,8 @@ func TestExecCommand_Run(t *testing.T) {
38
39
params : & chaos.GlobalParams {
39
40
Names : []string {"c1" , "c2" },
40
41
},
41
- command : "kill 1" ,
42
+ command : "kill" ,
43
+ args : []string {"-9" },
42
44
},
43
45
args : args {
44
46
ctx : context .TODO (),
@@ -52,7 +54,8 @@ func TestExecCommand_Run(t *testing.T) {
52
54
Names : []string {"c1" , "c2" , "c3" },
53
55
Labels : []string {"key=value" },
54
56
},
55
- command : "kill 1" ,
57
+ command : "ls" ,
58
+ args : []string {"-la" },
56
59
},
57
60
args : args {
58
61
ctx : context .TODO (),
@@ -65,7 +68,8 @@ func TestExecCommand_Run(t *testing.T) {
65
68
params : & chaos.GlobalParams {
66
69
Pattern : "^c?" ,
67
70
},
68
- command : "kill -STOP 1" ,
71
+ command : "kill" ,
72
+ args : []string {"-STOP" , "1" },
69
73
limit : 2 ,
70
74
},
71
75
args : args {
@@ -79,7 +83,8 @@ func TestExecCommand_Run(t *testing.T) {
79
83
params : & chaos.GlobalParams {
80
84
Names : []string {"c1" , "c2" , "c3" },
81
85
},
82
- command : "kill 1" ,
86
+ command : "kill" ,
87
+ args : []string {"1" },
83
88
},
84
89
args : args {
85
90
ctx : context .TODO (),
@@ -93,7 +98,8 @@ func TestExecCommand_Run(t *testing.T) {
93
98
params : & chaos.GlobalParams {
94
99
Names : []string {"c1" , "c2" , "c3" },
95
100
},
96
- command : "kill 1" ,
101
+ command : "kill" ,
102
+ args : []string {"1" },
97
103
},
98
104
args : args {
99
105
ctx : context .TODO (),
@@ -105,7 +111,8 @@ func TestExecCommand_Run(t *testing.T) {
105
111
params : & chaos.GlobalParams {
106
112
Names : []string {"c1" , "c2" , "c3" },
107
113
},
108
- command : "kill 1" ,
114
+ command : "kill" ,
115
+ args : []string {"1" },
109
116
},
110
117
args : args {
111
118
ctx : context .TODO (),
@@ -119,7 +126,8 @@ func TestExecCommand_Run(t *testing.T) {
119
126
params : & chaos.GlobalParams {
120
127
Names : []string {"c1" , "c2" , "c3" },
121
128
},
122
- command : "kill 1" ,
129
+ command : "kill" ,
130
+ args : []string {"1" },
123
131
},
124
132
args : args {
125
133
ctx : context .TODO (),
@@ -138,6 +146,7 @@ func TestExecCommand_Run(t *testing.T) {
138
146
pattern : tt .fields .params .Pattern ,
139
147
labels : tt .fields .params .Labels ,
140
148
command : tt .fields .command ,
149
+ args : tt .fields .args ,
141
150
limit : tt .fields .limit ,
142
151
dryRun : tt .fields .params .DryRun ,
143
152
}
@@ -153,11 +162,11 @@ func TestExecCommand_Run(t *testing.T) {
153
162
}
154
163
}
155
164
if tt .args .random {
156
- mockClient .On ("ExecContainer" , tt .args .ctx , mock .AnythingOfType ("*container.Container" ), tt .fields .command , tt .fields .params .DryRun ).Return (nil )
165
+ mockClient .On ("ExecContainer" , tt .args .ctx , mock .AnythingOfType ("*container.Container" ), tt .fields .command , tt .fields .args , tt . fields . params .DryRun ).Return (nil )
157
166
} else {
158
167
for i := range tt .expected {
159
168
if tt .fields .limit == 0 || i < tt .fields .limit {
160
- call = mockClient .On ("ExecContainer" , tt .args .ctx , mock .AnythingOfType ("*container.Container" ), tt .fields .command , tt .fields .params .DryRun )
169
+ call = mockClient .On ("ExecContainer" , tt .args .ctx , mock .AnythingOfType ("*container.Container" ), tt .fields .command , tt .fields .args , tt . fields . params .DryRun )
161
170
if tt .errs .execError {
162
171
call .Return (errors .New ("ERROR" ))
163
172
goto Invoke
0 commit comments