@@ -134,6 +134,10 @@ func (f *FakeRunner) CombinedOutput(cmd string) (string, error) {
134
134
return f .docker (args , root )
135
135
case "crictl" :
136
136
return f .crictl (args , root )
137
+ case "crio" :
138
+ return f .crio (args , root )
139
+ case "containerd" :
140
+ return f .containerd (args , root )
137
141
default :
138
142
return "" , nil
139
143
}
@@ -181,7 +185,29 @@ func (f *FakeRunner) docker(args []string, root bool) (string, error) {
181
185
delete (f .containers , id )
182
186
183
187
}
188
+ case "version" :
189
+ if args [1 ] == "--format" && args [2 ] == "'{{.Server.Version}}'" {
190
+ return "18.06.2-ce" , nil
191
+ }
192
+
193
+ }
194
+ return "" , nil
195
+ }
184
196
197
+ // crio is a fake implementation of crio
198
+ func (f * FakeRunner ) crio (args []string , root bool ) (string , error ) {
199
+ switch cmd := args [0 ]; cmd {
200
+ case "--version" :
201
+ return "crio version 1.13.0" , nil
202
+ }
203
+ return "" , nil
204
+ }
205
+
206
+ // containerd is a fake implementation of containerd
207
+ func (f * FakeRunner ) containerd (args []string , root bool ) (string , error ) {
208
+ switch cmd := args [0 ]; cmd {
209
+ case "--version" :
210
+ return "containerd github.com/containerd/containerd v1.2.0 c4446665cb9c30056f4998ed953e6d4ff22c7c39" , nil
185
211
}
186
212
return "" , nil
187
213
}
@@ -284,6 +310,33 @@ func (f *FakeRunner) systemctl(args []string, root bool) (string, error) {
284
310
return out , nil
285
311
}
286
312
313
+ func TestVersion (t * testing.T ) {
314
+ var tests = []struct {
315
+ runtime string
316
+ want string
317
+ }{
318
+ {"docker" , "18.06.2-ce" },
319
+ {"cri-o" , "1.13.0" },
320
+ {"containerd" , "1.2.0" },
321
+ }
322
+ for _ , tc := range tests {
323
+ t .Run (tc .runtime , func (t * testing.T ) {
324
+ runner := NewFakeRunner (t )
325
+ r , err := New (Config {Type : tc .runtime , Runner : runner })
326
+ if err != nil {
327
+ t .Fatalf ("New(%s): %v" , tc .runtime , err )
328
+ }
329
+ got , err := r .Version ()
330
+ if err != nil {
331
+ t .Fatalf ("Version(%s): %v" , tc .runtime , err )
332
+ }
333
+ if got != tc .want {
334
+ t .Errorf ("Version(%s) = %q, want: %q" , tc .runtime , got , tc .want )
335
+ }
336
+ })
337
+ }
338
+ }
339
+
287
340
// defaultServices reflects the default boot state for the minikube VM
288
341
var defaultServices = map [string ]serviceState {
289
342
"docker" : Running ,
0 commit comments