-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathregistry_client_mock.go
More file actions
1099 lines (893 loc) · 41.3 KB
/
registry_client_mock.go
File metadata and controls
1099 lines (893 loc) · 41.3 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by http://github.com/gojuno/minimock (v3.4.7). DO NOT EDIT.
package mock
//go:generate minimock -i github.com/deckhouse/module-sdk/pkg.RegistryClient -o registry_client_mock.go -n RegistryClientMock -p mock
import (
"context"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
v1 "github.com/google/go-containerregistry/pkg/v1"
)
// RegistryClientMock implements mm_pkg.RegistryClient
type RegistryClientMock struct {
t minimock.Tester
finishOnce sync.Once
funcDigest func(ctx context.Context, tag string) (s1 string, err error)
funcDigestOrigin string
inspectFuncDigest func(ctx context.Context, tag string)
afterDigestCounter uint64
beforeDigestCounter uint64
DigestMock mRegistryClientMockDigest
funcImage func(ctx context.Context, tag string) (i1 v1.Image, err error)
funcImageOrigin string
inspectFuncImage func(ctx context.Context, tag string)
afterImageCounter uint64
beforeImageCounter uint64
ImageMock mRegistryClientMockImage
funcListTags func(ctx context.Context) (sa1 []string, err error)
funcListTagsOrigin string
inspectFuncListTags func(ctx context.Context)
afterListTagsCounter uint64
beforeListTagsCounter uint64
ListTagsMock mRegistryClientMockListTags
}
// NewRegistryClientMock returns a mock for mm_pkg.RegistryClient
func NewRegistryClientMock(t minimock.Tester) *RegistryClientMock {
m := &RegistryClientMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.DigestMock = mRegistryClientMockDigest{mock: m}
m.DigestMock.callArgs = []*RegistryClientMockDigestParams{}
m.ImageMock = mRegistryClientMockImage{mock: m}
m.ImageMock.callArgs = []*RegistryClientMockImageParams{}
m.ListTagsMock = mRegistryClientMockListTags{mock: m}
m.ListTagsMock.callArgs = []*RegistryClientMockListTagsParams{}
t.Cleanup(m.MinimockFinish)
return m
}
type mRegistryClientMockDigest struct {
optional bool
mock *RegistryClientMock
defaultExpectation *RegistryClientMockDigestExpectation
expectations []*RegistryClientMockDigestExpectation
callArgs []*RegistryClientMockDigestParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// RegistryClientMockDigestExpectation specifies expectation struct of the RegistryClient.Digest
type RegistryClientMockDigestExpectation struct {
mock *RegistryClientMock
params *RegistryClientMockDigestParams
paramPtrs *RegistryClientMockDigestParamPtrs
expectationOrigins RegistryClientMockDigestExpectationOrigins
results *RegistryClientMockDigestResults
returnOrigin string
Counter uint64
}
// RegistryClientMockDigestParams contains parameters of the RegistryClient.Digest
type RegistryClientMockDigestParams struct {
ctx context.Context
tag string
}
// RegistryClientMockDigestParamPtrs contains pointers to parameters of the RegistryClient.Digest
type RegistryClientMockDigestParamPtrs struct {
ctx *context.Context
tag *string
}
// RegistryClientMockDigestResults contains results of the RegistryClient.Digest
type RegistryClientMockDigestResults struct {
s1 string
err error
}
// RegistryClientMockDigestOrigins contains origins of expectations of the RegistryClient.Digest
type RegistryClientMockDigestExpectationOrigins struct {
origin string
originCtx string
originTag string
}
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmDigest *mRegistryClientMockDigest) Optional() *mRegistryClientMockDigest {
mmDigest.optional = true
return mmDigest
}
// Expect sets up expected params for RegistryClient.Digest
func (mmDigest *mRegistryClientMockDigest) Expect(ctx context.Context, tag string) *mRegistryClientMockDigest {
if mmDigest.mock.funcDigest != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Set")
}
if mmDigest.defaultExpectation == nil {
mmDigest.defaultExpectation = &RegistryClientMockDigestExpectation{}
}
if mmDigest.defaultExpectation.paramPtrs != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by ExpectParams functions")
}
mmDigest.defaultExpectation.params = &RegistryClientMockDigestParams{ctx, tag}
mmDigest.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmDigest.expectations {
if minimock.Equal(e.params, mmDigest.defaultExpectation.params) {
mmDigest.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmDigest.defaultExpectation.params)
}
}
return mmDigest
}
// ExpectCtxParam1 sets up expected param ctx for RegistryClient.Digest
func (mmDigest *mRegistryClientMockDigest) ExpectCtxParam1(ctx context.Context) *mRegistryClientMockDigest {
if mmDigest.mock.funcDigest != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Set")
}
if mmDigest.defaultExpectation == nil {
mmDigest.defaultExpectation = &RegistryClientMockDigestExpectation{}
}
if mmDigest.defaultExpectation.params != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Expect")
}
if mmDigest.defaultExpectation.paramPtrs == nil {
mmDigest.defaultExpectation.paramPtrs = &RegistryClientMockDigestParamPtrs{}
}
mmDigest.defaultExpectation.paramPtrs.ctx = &ctx
mmDigest.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmDigest
}
// ExpectTagParam2 sets up expected param tag for RegistryClient.Digest
func (mmDigest *mRegistryClientMockDigest) ExpectTagParam2(tag string) *mRegistryClientMockDigest {
if mmDigest.mock.funcDigest != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Set")
}
if mmDigest.defaultExpectation == nil {
mmDigest.defaultExpectation = &RegistryClientMockDigestExpectation{}
}
if mmDigest.defaultExpectation.params != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Expect")
}
if mmDigest.defaultExpectation.paramPtrs == nil {
mmDigest.defaultExpectation.paramPtrs = &RegistryClientMockDigestParamPtrs{}
}
mmDigest.defaultExpectation.paramPtrs.tag = &tag
mmDigest.defaultExpectation.expectationOrigins.originTag = minimock.CallerInfo(1)
return mmDigest
}
// Inspect accepts an inspector function that has same arguments as the RegistryClient.Digest
func (mmDigest *mRegistryClientMockDigest) Inspect(f func(ctx context.Context, tag string)) *mRegistryClientMockDigest {
if mmDigest.mock.inspectFuncDigest != nil {
mmDigest.mock.t.Fatalf("Inspect function is already set for RegistryClientMock.Digest")
}
mmDigest.mock.inspectFuncDigest = f
return mmDigest
}
// Return sets up results that will be returned by RegistryClient.Digest
func (mmDigest *mRegistryClientMockDigest) Return(s1 string, err error) *RegistryClientMock {
if mmDigest.mock.funcDigest != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Set")
}
if mmDigest.defaultExpectation == nil {
mmDigest.defaultExpectation = &RegistryClientMockDigestExpectation{mock: mmDigest.mock}
}
mmDigest.defaultExpectation.results = &RegistryClientMockDigestResults{s1, err}
mmDigest.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmDigest.mock
}
// Set uses given function f to mock the RegistryClient.Digest method
func (mmDigest *mRegistryClientMockDigest) Set(f func(ctx context.Context, tag string) (s1 string, err error)) *RegistryClientMock {
if mmDigest.defaultExpectation != nil {
mmDigest.mock.t.Fatalf("Default expectation is already set for the RegistryClient.Digest method")
}
if len(mmDigest.expectations) > 0 {
mmDigest.mock.t.Fatalf("Some expectations are already set for the RegistryClient.Digest method")
}
mmDigest.mock.funcDigest = f
mmDigest.mock.funcDigestOrigin = minimock.CallerInfo(1)
return mmDigest.mock
}
// When sets expectation for the RegistryClient.Digest which will trigger the result defined by the following
// Then helper
func (mmDigest *mRegistryClientMockDigest) When(ctx context.Context, tag string) *RegistryClientMockDigestExpectation {
if mmDigest.mock.funcDigest != nil {
mmDigest.mock.t.Fatalf("RegistryClientMock.Digest mock is already set by Set")
}
expectation := &RegistryClientMockDigestExpectation{
mock: mmDigest.mock,
params: &RegistryClientMockDigestParams{ctx, tag},
expectationOrigins: RegistryClientMockDigestExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmDigest.expectations = append(mmDigest.expectations, expectation)
return expectation
}
// Then sets up RegistryClient.Digest return parameters for the expectation previously defined by the When method
func (e *RegistryClientMockDigestExpectation) Then(s1 string, err error) *RegistryClientMock {
e.results = &RegistryClientMockDigestResults{s1, err}
return e.mock
}
// Times sets number of times RegistryClient.Digest should be invoked
func (mmDigest *mRegistryClientMockDigest) Times(n uint64) *mRegistryClientMockDigest {
if n == 0 {
mmDigest.mock.t.Fatalf("Times of RegistryClientMock.Digest mock can not be zero")
}
mm_atomic.StoreUint64(&mmDigest.expectedInvocations, n)
mmDigest.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmDigest
}
func (mmDigest *mRegistryClientMockDigest) invocationsDone() bool {
if len(mmDigest.expectations) == 0 && mmDigest.defaultExpectation == nil && mmDigest.mock.funcDigest == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmDigest.mock.afterDigestCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmDigest.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Digest implements mm_pkg.RegistryClient
func (mmDigest *RegistryClientMock) Digest(ctx context.Context, tag string) (s1 string, err error) {
mm_atomic.AddUint64(&mmDigest.beforeDigestCounter, 1)
defer mm_atomic.AddUint64(&mmDigest.afterDigestCounter, 1)
mmDigest.t.Helper()
if mmDigest.inspectFuncDigest != nil {
mmDigest.inspectFuncDigest(ctx, tag)
}
mm_params := RegistryClientMockDigestParams{ctx, tag}
// Record call args
mmDigest.DigestMock.mutex.Lock()
mmDigest.DigestMock.callArgs = append(mmDigest.DigestMock.callArgs, &mm_params)
mmDigest.DigestMock.mutex.Unlock()
for _, e := range mmDigest.DigestMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.s1, e.results.err
}
}
if mmDigest.DigestMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmDigest.DigestMock.defaultExpectation.Counter, 1)
mm_want := mmDigest.DigestMock.defaultExpectation.params
mm_want_ptrs := mmDigest.DigestMock.defaultExpectation.paramPtrs
mm_got := RegistryClientMockDigestParams{ctx, tag}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmDigest.t.Errorf("RegistryClientMock.Digest got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmDigest.DigestMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
}
if mm_want_ptrs.tag != nil && !minimock.Equal(*mm_want_ptrs.tag, mm_got.tag) {
mmDigest.t.Errorf("RegistryClientMock.Digest got unexpected parameter tag, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmDigest.DigestMock.defaultExpectation.expectationOrigins.originTag, *mm_want_ptrs.tag, mm_got.tag, minimock.Diff(*mm_want_ptrs.tag, mm_got.tag))
}
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmDigest.t.Errorf("RegistryClientMock.Digest got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmDigest.DigestMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmDigest.DigestMock.defaultExpectation.results
if mm_results == nil {
mmDigest.t.Fatal("No results are set for the RegistryClientMock.Digest")
}
return (*mm_results).s1, (*mm_results).err
}
if mmDigest.funcDigest != nil {
return mmDigest.funcDigest(ctx, tag)
}
mmDigest.t.Fatalf("Unexpected call to RegistryClientMock.Digest. %v %v", ctx, tag)
return
}
// DigestAfterCounter returns a count of finished RegistryClientMock.Digest invocations
func (mmDigest *RegistryClientMock) DigestAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmDigest.afterDigestCounter)
}
// DigestBeforeCounter returns a count of RegistryClientMock.Digest invocations
func (mmDigest *RegistryClientMock) DigestBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmDigest.beforeDigestCounter)
}
// Calls returns a list of arguments used in each call to RegistryClientMock.Digest.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmDigest *mRegistryClientMockDigest) Calls() []*RegistryClientMockDigestParams {
mmDigest.mutex.RLock()
argCopy := make([]*RegistryClientMockDigestParams, len(mmDigest.callArgs))
copy(argCopy, mmDigest.callArgs)
mmDigest.mutex.RUnlock()
return argCopy
}
// MinimockDigestDone returns true if the count of the Digest invocations corresponds
// the number of defined expectations
func (m *RegistryClientMock) MinimockDigestDone() bool {
if m.DigestMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.DigestMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.DigestMock.invocationsDone()
}
// MinimockDigestInspect logs each unmet expectation
func (m *RegistryClientMock) MinimockDigestInspect() {
for _, e := range m.DigestMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to RegistryClientMock.Digest at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterDigestCounter := mm_atomic.LoadUint64(&m.afterDigestCounter)
// if default expectation was set then invocations count should be greater than zero
if m.DigestMock.defaultExpectation != nil && afterDigestCounter < 1 {
if m.DigestMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to RegistryClientMock.Digest at\n%s", m.DigestMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to RegistryClientMock.Digest at\n%s with params: %#v", m.DigestMock.defaultExpectation.expectationOrigins.origin, *m.DigestMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcDigest != nil && afterDigestCounter < 1 {
m.t.Errorf("Expected call to RegistryClientMock.Digest at\n%s", m.funcDigestOrigin)
}
if !m.DigestMock.invocationsDone() && afterDigestCounter > 0 {
m.t.Errorf("Expected %d calls to RegistryClientMock.Digest at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.DigestMock.expectedInvocations), m.DigestMock.expectedInvocationsOrigin, afterDigestCounter)
}
}
type mRegistryClientMockImage struct {
optional bool
mock *RegistryClientMock
defaultExpectation *RegistryClientMockImageExpectation
expectations []*RegistryClientMockImageExpectation
callArgs []*RegistryClientMockImageParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// RegistryClientMockImageExpectation specifies expectation struct of the RegistryClient.Image
type RegistryClientMockImageExpectation struct {
mock *RegistryClientMock
params *RegistryClientMockImageParams
paramPtrs *RegistryClientMockImageParamPtrs
expectationOrigins RegistryClientMockImageExpectationOrigins
results *RegistryClientMockImageResults
returnOrigin string
Counter uint64
}
// RegistryClientMockImageParams contains parameters of the RegistryClient.Image
type RegistryClientMockImageParams struct {
ctx context.Context
tag string
}
// RegistryClientMockImageParamPtrs contains pointers to parameters of the RegistryClient.Image
type RegistryClientMockImageParamPtrs struct {
ctx *context.Context
tag *string
}
// RegistryClientMockImageResults contains results of the RegistryClient.Image
type RegistryClientMockImageResults struct {
i1 v1.Image
err error
}
// RegistryClientMockImageOrigins contains origins of expectations of the RegistryClient.Image
type RegistryClientMockImageExpectationOrigins struct {
origin string
originCtx string
originTag string
}
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmImage *mRegistryClientMockImage) Optional() *mRegistryClientMockImage {
mmImage.optional = true
return mmImage
}
// Expect sets up expected params for RegistryClient.Image
func (mmImage *mRegistryClientMockImage) Expect(ctx context.Context, tag string) *mRegistryClientMockImage {
if mmImage.mock.funcImage != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Set")
}
if mmImage.defaultExpectation == nil {
mmImage.defaultExpectation = &RegistryClientMockImageExpectation{}
}
if mmImage.defaultExpectation.paramPtrs != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by ExpectParams functions")
}
mmImage.defaultExpectation.params = &RegistryClientMockImageParams{ctx, tag}
mmImage.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmImage.expectations {
if minimock.Equal(e.params, mmImage.defaultExpectation.params) {
mmImage.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmImage.defaultExpectation.params)
}
}
return mmImage
}
// ExpectCtxParam1 sets up expected param ctx for RegistryClient.Image
func (mmImage *mRegistryClientMockImage) ExpectCtxParam1(ctx context.Context) *mRegistryClientMockImage {
if mmImage.mock.funcImage != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Set")
}
if mmImage.defaultExpectation == nil {
mmImage.defaultExpectation = &RegistryClientMockImageExpectation{}
}
if mmImage.defaultExpectation.params != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Expect")
}
if mmImage.defaultExpectation.paramPtrs == nil {
mmImage.defaultExpectation.paramPtrs = &RegistryClientMockImageParamPtrs{}
}
mmImage.defaultExpectation.paramPtrs.ctx = &ctx
mmImage.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmImage
}
// ExpectTagParam2 sets up expected param tag for RegistryClient.Image
func (mmImage *mRegistryClientMockImage) ExpectTagParam2(tag string) *mRegistryClientMockImage {
if mmImage.mock.funcImage != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Set")
}
if mmImage.defaultExpectation == nil {
mmImage.defaultExpectation = &RegistryClientMockImageExpectation{}
}
if mmImage.defaultExpectation.params != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Expect")
}
if mmImage.defaultExpectation.paramPtrs == nil {
mmImage.defaultExpectation.paramPtrs = &RegistryClientMockImageParamPtrs{}
}
mmImage.defaultExpectation.paramPtrs.tag = &tag
mmImage.defaultExpectation.expectationOrigins.originTag = minimock.CallerInfo(1)
return mmImage
}
// Inspect accepts an inspector function that has same arguments as the RegistryClient.Image
func (mmImage *mRegistryClientMockImage) Inspect(f func(ctx context.Context, tag string)) *mRegistryClientMockImage {
if mmImage.mock.inspectFuncImage != nil {
mmImage.mock.t.Fatalf("Inspect function is already set for RegistryClientMock.Image")
}
mmImage.mock.inspectFuncImage = f
return mmImage
}
// Return sets up results that will be returned by RegistryClient.Image
func (mmImage *mRegistryClientMockImage) Return(i1 v1.Image, err error) *RegistryClientMock {
if mmImage.mock.funcImage != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Set")
}
if mmImage.defaultExpectation == nil {
mmImage.defaultExpectation = &RegistryClientMockImageExpectation{mock: mmImage.mock}
}
mmImage.defaultExpectation.results = &RegistryClientMockImageResults{i1, err}
mmImage.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmImage.mock
}
// Set uses given function f to mock the RegistryClient.Image method
func (mmImage *mRegistryClientMockImage) Set(f func(ctx context.Context, tag string) (i1 v1.Image, err error)) *RegistryClientMock {
if mmImage.defaultExpectation != nil {
mmImage.mock.t.Fatalf("Default expectation is already set for the RegistryClient.Image method")
}
if len(mmImage.expectations) > 0 {
mmImage.mock.t.Fatalf("Some expectations are already set for the RegistryClient.Image method")
}
mmImage.mock.funcImage = f
mmImage.mock.funcImageOrigin = minimock.CallerInfo(1)
return mmImage.mock
}
// When sets expectation for the RegistryClient.Image which will trigger the result defined by the following
// Then helper
func (mmImage *mRegistryClientMockImage) When(ctx context.Context, tag string) *RegistryClientMockImageExpectation {
if mmImage.mock.funcImage != nil {
mmImage.mock.t.Fatalf("RegistryClientMock.Image mock is already set by Set")
}
expectation := &RegistryClientMockImageExpectation{
mock: mmImage.mock,
params: &RegistryClientMockImageParams{ctx, tag},
expectationOrigins: RegistryClientMockImageExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmImage.expectations = append(mmImage.expectations, expectation)
return expectation
}
// Then sets up RegistryClient.Image return parameters for the expectation previously defined by the When method
func (e *RegistryClientMockImageExpectation) Then(i1 v1.Image, err error) *RegistryClientMock {
e.results = &RegistryClientMockImageResults{i1, err}
return e.mock
}
// Times sets number of times RegistryClient.Image should be invoked
func (mmImage *mRegistryClientMockImage) Times(n uint64) *mRegistryClientMockImage {
if n == 0 {
mmImage.mock.t.Fatalf("Times of RegistryClientMock.Image mock can not be zero")
}
mm_atomic.StoreUint64(&mmImage.expectedInvocations, n)
mmImage.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmImage
}
func (mmImage *mRegistryClientMockImage) invocationsDone() bool {
if len(mmImage.expectations) == 0 && mmImage.defaultExpectation == nil && mmImage.mock.funcImage == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmImage.mock.afterImageCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmImage.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// Image implements mm_pkg.RegistryClient
func (mmImage *RegistryClientMock) Image(ctx context.Context, tag string) (i1 v1.Image, err error) {
mm_atomic.AddUint64(&mmImage.beforeImageCounter, 1)
defer mm_atomic.AddUint64(&mmImage.afterImageCounter, 1)
mmImage.t.Helper()
if mmImage.inspectFuncImage != nil {
mmImage.inspectFuncImage(ctx, tag)
}
mm_params := RegistryClientMockImageParams{ctx, tag}
// Record call args
mmImage.ImageMock.mutex.Lock()
mmImage.ImageMock.callArgs = append(mmImage.ImageMock.callArgs, &mm_params)
mmImage.ImageMock.mutex.Unlock()
for _, e := range mmImage.ImageMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.i1, e.results.err
}
}
if mmImage.ImageMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmImage.ImageMock.defaultExpectation.Counter, 1)
mm_want := mmImage.ImageMock.defaultExpectation.params
mm_want_ptrs := mmImage.ImageMock.defaultExpectation.paramPtrs
mm_got := RegistryClientMockImageParams{ctx, tag}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmImage.t.Errorf("RegistryClientMock.Image got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmImage.ImageMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
}
if mm_want_ptrs.tag != nil && !minimock.Equal(*mm_want_ptrs.tag, mm_got.tag) {
mmImage.t.Errorf("RegistryClientMock.Image got unexpected parameter tag, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmImage.ImageMock.defaultExpectation.expectationOrigins.originTag, *mm_want_ptrs.tag, mm_got.tag, minimock.Diff(*mm_want_ptrs.tag, mm_got.tag))
}
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmImage.t.Errorf("RegistryClientMock.Image got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmImage.ImageMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmImage.ImageMock.defaultExpectation.results
if mm_results == nil {
mmImage.t.Fatal("No results are set for the RegistryClientMock.Image")
}
return (*mm_results).i1, (*mm_results).err
}
if mmImage.funcImage != nil {
return mmImage.funcImage(ctx, tag)
}
mmImage.t.Fatalf("Unexpected call to RegistryClientMock.Image. %v %v", ctx, tag)
return
}
// ImageAfterCounter returns a count of finished RegistryClientMock.Image invocations
func (mmImage *RegistryClientMock) ImageAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmImage.afterImageCounter)
}
// ImageBeforeCounter returns a count of RegistryClientMock.Image invocations
func (mmImage *RegistryClientMock) ImageBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmImage.beforeImageCounter)
}
// Calls returns a list of arguments used in each call to RegistryClientMock.Image.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmImage *mRegistryClientMockImage) Calls() []*RegistryClientMockImageParams {
mmImage.mutex.RLock()
argCopy := make([]*RegistryClientMockImageParams, len(mmImage.callArgs))
copy(argCopy, mmImage.callArgs)
mmImage.mutex.RUnlock()
return argCopy
}
// MinimockImageDone returns true if the count of the Image invocations corresponds
// the number of defined expectations
func (m *RegistryClientMock) MinimockImageDone() bool {
if m.ImageMock.optional {
// Optional methods provide '0 or more' call count restriction.
return true
}
for _, e := range m.ImageMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
return m.ImageMock.invocationsDone()
}
// MinimockImageInspect logs each unmet expectation
func (m *RegistryClientMock) MinimockImageInspect() {
for _, e := range m.ImageMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to RegistryClientMock.Image at\n%s with params: %#v", e.expectationOrigins.origin, *e.params)
}
}
afterImageCounter := mm_atomic.LoadUint64(&m.afterImageCounter)
// if default expectation was set then invocations count should be greater than zero
if m.ImageMock.defaultExpectation != nil && afterImageCounter < 1 {
if m.ImageMock.defaultExpectation.params == nil {
m.t.Errorf("Expected call to RegistryClientMock.Image at\n%s", m.ImageMock.defaultExpectation.returnOrigin)
} else {
m.t.Errorf("Expected call to RegistryClientMock.Image at\n%s with params: %#v", m.ImageMock.defaultExpectation.expectationOrigins.origin, *m.ImageMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcImage != nil && afterImageCounter < 1 {
m.t.Errorf("Expected call to RegistryClientMock.Image at\n%s", m.funcImageOrigin)
}
if !m.ImageMock.invocationsDone() && afterImageCounter > 0 {
m.t.Errorf("Expected %d calls to RegistryClientMock.Image at\n%s but found %d calls",
mm_atomic.LoadUint64(&m.ImageMock.expectedInvocations), m.ImageMock.expectedInvocationsOrigin, afterImageCounter)
}
}
type mRegistryClientMockListTags struct {
optional bool
mock *RegistryClientMock
defaultExpectation *RegistryClientMockListTagsExpectation
expectations []*RegistryClientMockListTagsExpectation
callArgs []*RegistryClientMockListTagsParams
mutex sync.RWMutex
expectedInvocations uint64
expectedInvocationsOrigin string
}
// RegistryClientMockListTagsExpectation specifies expectation struct of the RegistryClient.ListTags
type RegistryClientMockListTagsExpectation struct {
mock *RegistryClientMock
params *RegistryClientMockListTagsParams
paramPtrs *RegistryClientMockListTagsParamPtrs
expectationOrigins RegistryClientMockListTagsExpectationOrigins
results *RegistryClientMockListTagsResults
returnOrigin string
Counter uint64
}
// RegistryClientMockListTagsParams contains parameters of the RegistryClient.ListTags
type RegistryClientMockListTagsParams struct {
ctx context.Context
}
// RegistryClientMockListTagsParamPtrs contains pointers to parameters of the RegistryClient.ListTags
type RegistryClientMockListTagsParamPtrs struct {
ctx *context.Context
}
// RegistryClientMockListTagsResults contains results of the RegistryClient.ListTags
type RegistryClientMockListTagsResults struct {
sa1 []string
err error
}
// RegistryClientMockListTagsOrigins contains origins of expectations of the RegistryClient.ListTags
type RegistryClientMockListTagsExpectationOrigins struct {
origin string
originCtx string
}
// Marks this method to be optional. The default behavior of any method with Return() is '1 or more', meaning
// the test will fail minimock's automatic final call check if the mocked method was not called at least once.
// Optional() makes method check to work in '0 or more' mode.
// It is NOT RECOMMENDED to use this option unless you really need it, as default behaviour helps to
// catch the problems when the expected method call is totally skipped during test run.
func (mmListTags *mRegistryClientMockListTags) Optional() *mRegistryClientMockListTags {
mmListTags.optional = true
return mmListTags
}
// Expect sets up expected params for RegistryClient.ListTags
func (mmListTags *mRegistryClientMockListTags) Expect(ctx context.Context) *mRegistryClientMockListTags {
if mmListTags.mock.funcListTags != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by Set")
}
if mmListTags.defaultExpectation == nil {
mmListTags.defaultExpectation = &RegistryClientMockListTagsExpectation{}
}
if mmListTags.defaultExpectation.paramPtrs != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by ExpectParams functions")
}
mmListTags.defaultExpectation.params = &RegistryClientMockListTagsParams{ctx}
mmListTags.defaultExpectation.expectationOrigins.origin = minimock.CallerInfo(1)
for _, e := range mmListTags.expectations {
if minimock.Equal(e.params, mmListTags.defaultExpectation.params) {
mmListTags.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmListTags.defaultExpectation.params)
}
}
return mmListTags
}
// ExpectCtxParam1 sets up expected param ctx for RegistryClient.ListTags
func (mmListTags *mRegistryClientMockListTags) ExpectCtxParam1(ctx context.Context) *mRegistryClientMockListTags {
if mmListTags.mock.funcListTags != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by Set")
}
if mmListTags.defaultExpectation == nil {
mmListTags.defaultExpectation = &RegistryClientMockListTagsExpectation{}
}
if mmListTags.defaultExpectation.params != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by Expect")
}
if mmListTags.defaultExpectation.paramPtrs == nil {
mmListTags.defaultExpectation.paramPtrs = &RegistryClientMockListTagsParamPtrs{}
}
mmListTags.defaultExpectation.paramPtrs.ctx = &ctx
mmListTags.defaultExpectation.expectationOrigins.originCtx = minimock.CallerInfo(1)
return mmListTags
}
// Inspect accepts an inspector function that has same arguments as the RegistryClient.ListTags
func (mmListTags *mRegistryClientMockListTags) Inspect(f func(ctx context.Context)) *mRegistryClientMockListTags {
if mmListTags.mock.inspectFuncListTags != nil {
mmListTags.mock.t.Fatalf("Inspect function is already set for RegistryClientMock.ListTags")
}
mmListTags.mock.inspectFuncListTags = f
return mmListTags
}
// Return sets up results that will be returned by RegistryClient.ListTags
func (mmListTags *mRegistryClientMockListTags) Return(sa1 []string, err error) *RegistryClientMock {
if mmListTags.mock.funcListTags != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by Set")
}
if mmListTags.defaultExpectation == nil {
mmListTags.defaultExpectation = &RegistryClientMockListTagsExpectation{mock: mmListTags.mock}
}
mmListTags.defaultExpectation.results = &RegistryClientMockListTagsResults{sa1, err}
mmListTags.defaultExpectation.returnOrigin = minimock.CallerInfo(1)
return mmListTags.mock
}
// Set uses given function f to mock the RegistryClient.ListTags method
func (mmListTags *mRegistryClientMockListTags) Set(f func(ctx context.Context) (sa1 []string, err error)) *RegistryClientMock {
if mmListTags.defaultExpectation != nil {
mmListTags.mock.t.Fatalf("Default expectation is already set for the RegistryClient.ListTags method")
}
if len(mmListTags.expectations) > 0 {
mmListTags.mock.t.Fatalf("Some expectations are already set for the RegistryClient.ListTags method")
}
mmListTags.mock.funcListTags = f
mmListTags.mock.funcListTagsOrigin = minimock.CallerInfo(1)
return mmListTags.mock
}
// When sets expectation for the RegistryClient.ListTags which will trigger the result defined by the following
// Then helper
func (mmListTags *mRegistryClientMockListTags) When(ctx context.Context) *RegistryClientMockListTagsExpectation {
if mmListTags.mock.funcListTags != nil {
mmListTags.mock.t.Fatalf("RegistryClientMock.ListTags mock is already set by Set")
}
expectation := &RegistryClientMockListTagsExpectation{
mock: mmListTags.mock,
params: &RegistryClientMockListTagsParams{ctx},
expectationOrigins: RegistryClientMockListTagsExpectationOrigins{origin: minimock.CallerInfo(1)},
}
mmListTags.expectations = append(mmListTags.expectations, expectation)
return expectation
}
// Then sets up RegistryClient.ListTags return parameters for the expectation previously defined by the When method
func (e *RegistryClientMockListTagsExpectation) Then(sa1 []string, err error) *RegistryClientMock {
e.results = &RegistryClientMockListTagsResults{sa1, err}
return e.mock
}
// Times sets number of times RegistryClient.ListTags should be invoked
func (mmListTags *mRegistryClientMockListTags) Times(n uint64) *mRegistryClientMockListTags {
if n == 0 {
mmListTags.mock.t.Fatalf("Times of RegistryClientMock.ListTags mock can not be zero")
}
mm_atomic.StoreUint64(&mmListTags.expectedInvocations, n)
mmListTags.expectedInvocationsOrigin = minimock.CallerInfo(1)
return mmListTags
}
func (mmListTags *mRegistryClientMockListTags) invocationsDone() bool {
if len(mmListTags.expectations) == 0 && mmListTags.defaultExpectation == nil && mmListTags.mock.funcListTags == nil {
return true
}
totalInvocations := mm_atomic.LoadUint64(&mmListTags.mock.afterListTagsCounter)
expectedInvocations := mm_atomic.LoadUint64(&mmListTags.expectedInvocations)
return totalInvocations > 0 && (expectedInvocations == 0 || expectedInvocations == totalInvocations)
}
// ListTags implements mm_pkg.RegistryClient
func (mmListTags *RegistryClientMock) ListTags(ctx context.Context) (sa1 []string, err error) {
mm_atomic.AddUint64(&mmListTags.beforeListTagsCounter, 1)
defer mm_atomic.AddUint64(&mmListTags.afterListTagsCounter, 1)
mmListTags.t.Helper()
if mmListTags.inspectFuncListTags != nil {
mmListTags.inspectFuncListTags(ctx)
}
mm_params := RegistryClientMockListTagsParams{ctx}
// Record call args
mmListTags.ListTagsMock.mutex.Lock()
mmListTags.ListTagsMock.callArgs = append(mmListTags.ListTagsMock.callArgs, &mm_params)
mmListTags.ListTagsMock.mutex.Unlock()
for _, e := range mmListTags.ListTagsMock.expectations {
if minimock.Equal(*e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.sa1, e.results.err
}
}
if mmListTags.ListTagsMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmListTags.ListTagsMock.defaultExpectation.Counter, 1)
mm_want := mmListTags.ListTagsMock.defaultExpectation.params
mm_want_ptrs := mmListTags.ListTagsMock.defaultExpectation.paramPtrs
mm_got := RegistryClientMockListTagsParams{ctx}
if mm_want_ptrs != nil {
if mm_want_ptrs.ctx != nil && !minimock.Equal(*mm_want_ptrs.ctx, mm_got.ctx) {
mmListTags.t.Errorf("RegistryClientMock.ListTags got unexpected parameter ctx, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmListTags.ListTagsMock.defaultExpectation.expectationOrigins.originCtx, *mm_want_ptrs.ctx, mm_got.ctx, minimock.Diff(*mm_want_ptrs.ctx, mm_got.ctx))
}
} else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmListTags.t.Errorf("RegistryClientMock.ListTags got unexpected parameters, expected at\n%s:\nwant: %#v\n got: %#v%s\n",
mmListTags.ListTagsMock.defaultExpectation.expectationOrigins.origin, *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmListTags.ListTagsMock.defaultExpectation.results
if mm_results == nil {
mmListTags.t.Fatal("No results are set for the RegistryClientMock.ListTags")
}
return (*mm_results).sa1, (*mm_results).err
}
if mmListTags.funcListTags != nil {
return mmListTags.funcListTags(ctx)
}
mmListTags.t.Fatalf("Unexpected call to RegistryClientMock.ListTags. %v", ctx)
return
}
// ListTagsAfterCounter returns a count of finished RegistryClientMock.ListTags invocations
func (mmListTags *RegistryClientMock) ListTagsAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmListTags.afterListTagsCounter)
}