@@ -126,6 +126,7 @@ func (r *FakeRuntimeService) popError(f string) error {
126
126
return nil
127
127
}
128
128
err , errs := errs [0 ], errs [1 :]
129
+ r .Errors [f ] = errs
129
130
return err
130
131
}
131
132
@@ -144,6 +145,9 @@ func (r *FakeRuntimeService) Version(apiVersion string) (*runtimeapi.VersionResp
144
145
defer r .Unlock ()
145
146
146
147
r .Called = append (r .Called , "Version" )
148
+ if err := r .popError ("Version" ); err != nil {
149
+ return nil , err
150
+ }
147
151
148
152
return & runtimeapi.VersionResponse {
149
153
Version : FakeVersion ,
@@ -158,6 +162,9 @@ func (r *FakeRuntimeService) Status() (*runtimeapi.RuntimeStatus, error) {
158
162
defer r .Unlock ()
159
163
160
164
r .Called = append (r .Called , "Status" )
165
+ if err := r .popError ("Status" ); err != nil {
166
+ return nil , err
167
+ }
161
168
162
169
return r .FakeStatus , nil
163
170
}
@@ -167,6 +174,9 @@ func (r *FakeRuntimeService) RunPodSandbox(config *runtimeapi.PodSandboxConfig,
167
174
defer r .Unlock ()
168
175
169
176
r .Called = append (r .Called , "RunPodSandbox" )
177
+ if err := r .popError ("RunPodSandbox" ); err != nil {
178
+ return "" , err
179
+ }
170
180
171
181
// PodSandboxID should be randomized for real container runtime, but here just use
172
182
// fixed name from BuildSandboxName() for easily making fake sandboxes.
@@ -196,6 +206,9 @@ func (r *FakeRuntimeService) StopPodSandbox(podSandboxID string) error {
196
206
defer r .Unlock ()
197
207
198
208
r .Called = append (r .Called , "StopPodSandbox" )
209
+ if err := r .popError ("StopPodSandbox" ); err != nil {
210
+ return err
211
+ }
199
212
200
213
if s , ok := r .Sandboxes [podSandboxID ]; ok {
201
214
s .State = runtimeapi .PodSandboxState_SANDBOX_NOTREADY
@@ -211,6 +224,9 @@ func (r *FakeRuntimeService) RemovePodSandbox(podSandboxID string) error {
211
224
defer r .Unlock ()
212
225
213
226
r .Called = append (r .Called , "RemovePodSandbox" )
227
+ if err := r .popError ("RemovePodSandbox" ); err != nil {
228
+ return err
229
+ }
214
230
215
231
// Remove the pod sandbox
216
232
delete (r .Sandboxes , podSandboxID )
@@ -223,6 +239,9 @@ func (r *FakeRuntimeService) PodSandboxStatus(podSandboxID string) (*runtimeapi.
223
239
defer r .Unlock ()
224
240
225
241
r .Called = append (r .Called , "PodSandboxStatus" )
242
+ if err := r .popError ("PodSandboxStatus" ); err != nil {
243
+ return nil , err
244
+ }
226
245
227
246
s , ok := r .Sandboxes [podSandboxID ]
228
247
if ! ok {
@@ -238,6 +257,9 @@ func (r *FakeRuntimeService) ListPodSandbox(filter *runtimeapi.PodSandboxFilter)
238
257
defer r .Unlock ()
239
258
240
259
r .Called = append (r .Called , "ListPodSandbox" )
260
+ if err := r .popError ("ListPodSandbox" ); err != nil {
261
+ return nil , err
262
+ }
241
263
242
264
result := make ([]* runtimeapi.PodSandbox , 0 )
243
265
for id , s := range r .Sandboxes {
@@ -272,6 +294,10 @@ func (r *FakeRuntimeService) PortForward(*runtimeapi.PortForwardRequest) (*runti
272
294
defer r .Unlock ()
273
295
274
296
r .Called = append (r .Called , "PortForward" )
297
+ if err := r .popError ("PortForward" ); err != nil {
298
+ return nil , err
299
+ }
300
+
275
301
return & runtimeapi.PortForwardResponse {}, nil
276
302
}
277
303
@@ -280,6 +306,9 @@ func (r *FakeRuntimeService) CreateContainer(podSandboxID string, config *runtim
280
306
defer r .Unlock ()
281
307
282
308
r .Called = append (r .Called , "CreateContainer" )
309
+ if err := r .popError ("CreateContainer" ); err != nil {
310
+ return "" , err
311
+ }
283
312
284
313
// ContainerID should be randomized for real container runtime, but here just use
285
314
// fixed BuildContainerName() for easily making fake containers.
@@ -309,6 +338,9 @@ func (r *FakeRuntimeService) StartContainer(containerID string) error {
309
338
defer r .Unlock ()
310
339
311
340
r .Called = append (r .Called , "StartContainer" )
341
+ if err := r .popError ("StartContainer" ); err != nil {
342
+ return err
343
+ }
312
344
313
345
c , ok := r .Containers [containerID ]
314
346
if ! ok {
@@ -327,6 +359,9 @@ func (r *FakeRuntimeService) StopContainer(containerID string, timeout int64) er
327
359
defer r .Unlock ()
328
360
329
361
r .Called = append (r .Called , "StopContainer" )
362
+ if err := r .popError ("StopContainer" ); err != nil {
363
+ return err
364
+ }
330
365
331
366
c , ok := r .Containers [containerID ]
332
367
if ! ok {
@@ -347,6 +382,9 @@ func (r *FakeRuntimeService) RemoveContainer(containerID string) error {
347
382
defer r .Unlock ()
348
383
349
384
r .Called = append (r .Called , "RemoveContainer" )
385
+ if err := r .popError ("RemoveContainer" ); err != nil {
386
+ return err
387
+ }
350
388
351
389
// Remove the container
352
390
delete (r .Containers , containerID )
@@ -359,6 +397,9 @@ func (r *FakeRuntimeService) ListContainers(filter *runtimeapi.ContainerFilter)
359
397
defer r .Unlock ()
360
398
361
399
r .Called = append (r .Called , "ListContainers" )
400
+ if err := r .popError ("ListContainers" ); err != nil {
401
+ return nil , err
402
+ }
362
403
363
404
result := make ([]* runtimeapi.Container , 0 )
364
405
for _ , s := range r .Containers {
@@ -398,6 +439,9 @@ func (r *FakeRuntimeService) ContainerStatus(containerID string) (*runtimeapi.Co
398
439
defer r .Unlock ()
399
440
400
441
r .Called = append (r .Called , "ContainerStatus" )
442
+ if err := r .popError ("ContainerStatus" ); err != nil {
443
+ return nil , err
444
+ }
401
445
402
446
c , ok := r .Containers [containerID ]
403
447
if ! ok {
@@ -413,22 +457,27 @@ func (r *FakeRuntimeService) UpdateContainerResources(string, *runtimeapi.LinuxC
413
457
defer r .Unlock ()
414
458
415
459
r .Called = append (r .Called , "UpdateContainerResources" )
416
- return nil
460
+ return r . popError ( "UpdateContainerResources" )
417
461
}
418
462
419
463
func (r * FakeRuntimeService ) ExecSync (containerID string , cmd []string , timeout time.Duration ) (stdout []byte , stderr []byte , err error ) {
420
464
r .Lock ()
421
465
defer r .Unlock ()
422
466
423
467
r .Called = append (r .Called , "ExecSync" )
424
- return nil , nil , nil
468
+ err = r .popError ("ExecSync" )
469
+ return
425
470
}
426
471
427
472
func (r * FakeRuntimeService ) Exec (* runtimeapi.ExecRequest ) (* runtimeapi.ExecResponse , error ) {
428
473
r .Lock ()
429
474
defer r .Unlock ()
430
475
431
476
r .Called = append (r .Called , "Exec" )
477
+ if err := r .popError ("Exec" ); err != nil {
478
+ return nil , err
479
+ }
480
+
432
481
return & runtimeapi.ExecResponse {}, nil
433
482
}
434
483
@@ -437,11 +486,19 @@ func (r *FakeRuntimeService) Attach(req *runtimeapi.AttachRequest) (*runtimeapi.
437
486
defer r .Unlock ()
438
487
439
488
r .Called = append (r .Called , "Attach" )
489
+ if err := r .popError ("Attach" ); err != nil {
490
+ return nil , err
491
+ }
492
+
440
493
return & runtimeapi.AttachResponse {}, nil
441
494
}
442
495
443
496
func (r * FakeRuntimeService ) UpdateRuntimeConfig (runtimeCOnfig * runtimeapi.RuntimeConfig ) error {
444
- return nil
497
+ r .Lock ()
498
+ defer r .Unlock ()
499
+
500
+ r .Called = append (r .Called , "UpdateRuntimeConfig" )
501
+ return r .popError ("UpdateRuntimeConfig" )
445
502
}
446
503
447
504
func (r * FakeRuntimeService ) SetFakeContainerStats (containerStats []* runtimeapi.ContainerStats ) {
@@ -459,6 +516,9 @@ func (r *FakeRuntimeService) ContainerStats(containerID string) (*runtimeapi.Con
459
516
defer r .Unlock ()
460
517
461
518
r .Called = append (r .Called , "ContainerStats" )
519
+ if err := r .popError ("ContainerStats" ); err != nil {
520
+ return nil , err
521
+ }
462
522
463
523
s , found := r .FakeContainerStats [containerID ]
464
524
if ! found {
@@ -472,6 +532,9 @@ func (r *FakeRuntimeService) ListContainerStats(filter *runtimeapi.ContainerStat
472
532
defer r .Unlock ()
473
533
474
534
r .Called = append (r .Called , "ListContainerStats" )
535
+ if err := r .popError ("ListContainerStats" ); err != nil {
536
+ return nil , err
537
+ }
475
538
476
539
var result []* runtimeapi.ContainerStats
477
540
for _ , c := range r .Containers {
0 commit comments