-
Notifications
You must be signed in to change notification settings - Fork 46
/
coordinator_mock.go
3199 lines (2643 loc) · 139 KB
/
coordinator_mock.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
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
package jet
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"context"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock"
"github.com/insolar/insolar/insolar"
)
// CoordinatorMock implements Coordinator
type CoordinatorMock struct {
t minimock.Tester
funcHeavy func(ctx context.Context) (rp1 *insolar.Reference, err error)
inspectFuncHeavy func(ctx context.Context)
afterHeavyCounter uint64
beforeHeavyCounter uint64
HeavyMock mCoordinatorMockHeavy
funcIsAuthorized func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference) (b1 bool, err error)
inspectFuncIsAuthorized func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference)
afterIsAuthorizedCounter uint64
beforeIsAuthorizedCounter uint64
IsAuthorizedMock mCoordinatorMockIsAuthorized
funcIsBeyondLimit func(ctx context.Context, targetPN insolar.PulseNumber) (b1 bool, err error)
inspectFuncIsBeyondLimit func(ctx context.Context, targetPN insolar.PulseNumber)
afterIsBeyondLimitCounter uint64
beforeIsBeyondLimitCounter uint64
IsBeyondLimitMock mCoordinatorMockIsBeyondLimit
funcIsMeAuthorizedNow func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID) (b1 bool, err error)
inspectFuncIsMeAuthorizedNow func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID)
afterIsMeAuthorizedNowCounter uint64
beforeIsMeAuthorizedNowCounter uint64
IsMeAuthorizedNowMock mCoordinatorMockIsMeAuthorizedNow
funcLightExecutorForJet func(ctx context.Context, jetID insolar.ID, pulse insolar.PulseNumber) (rp1 *insolar.Reference, err error)
inspectFuncLightExecutorForJet func(ctx context.Context, jetID insolar.ID, pulse insolar.PulseNumber)
afterLightExecutorForJetCounter uint64
beforeLightExecutorForJetCounter uint64
LightExecutorForJetMock mCoordinatorMockLightExecutorForJet
funcLightExecutorForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber) (rp1 *insolar.Reference, err error)
inspectFuncLightExecutorForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber)
afterLightExecutorForObjectCounter uint64
beforeLightExecutorForObjectCounter uint64
LightExecutorForObjectMock mCoordinatorMockLightExecutorForObject
funcLightValidatorsForJet func(ctx context.Context, jetID insolar.ID, pulse insolar.PulseNumber) (ra1 []insolar.Reference, err error)
inspectFuncLightValidatorsForJet func(ctx context.Context, jetID insolar.ID, pulse insolar.PulseNumber)
afterLightValidatorsForJetCounter uint64
beforeLightValidatorsForJetCounter uint64
LightValidatorsForJetMock mCoordinatorMockLightValidatorsForJet
funcLightValidatorsForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber) (ra1 []insolar.Reference, err error)
inspectFuncLightValidatorsForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber)
afterLightValidatorsForObjectCounter uint64
beforeLightValidatorsForObjectCounter uint64
LightValidatorsForObjectMock mCoordinatorMockLightValidatorsForObject
funcMe func() (r1 insolar.Reference)
inspectFuncMe func()
afterMeCounter uint64
beforeMeCounter uint64
MeMock mCoordinatorMockMe
funcNodeForJet func(ctx context.Context, jetID insolar.ID, targetPN insolar.PulseNumber) (rp1 *insolar.Reference, err error)
inspectFuncNodeForJet func(ctx context.Context, jetID insolar.ID, targetPN insolar.PulseNumber)
afterNodeForJetCounter uint64
beforeNodeForJetCounter uint64
NodeForJetMock mCoordinatorMockNodeForJet
funcNodeForObject func(ctx context.Context, objectID insolar.ID, targetPN insolar.PulseNumber) (rp1 *insolar.Reference, err error)
inspectFuncNodeForObject func(ctx context.Context, objectID insolar.ID, targetPN insolar.PulseNumber)
afterNodeForObjectCounter uint64
beforeNodeForObjectCounter uint64
NodeForObjectMock mCoordinatorMockNodeForObject
funcQueryRole func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber) (ra1 []insolar.Reference, err error)
inspectFuncQueryRole func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber)
afterQueryRoleCounter uint64
beforeQueryRoleCounter uint64
QueryRoleMock mCoordinatorMockQueryRole
funcVirtualExecutorForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber) (rp1 *insolar.Reference, err error)
inspectFuncVirtualExecutorForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber)
afterVirtualExecutorForObjectCounter uint64
beforeVirtualExecutorForObjectCounter uint64
VirtualExecutorForObjectMock mCoordinatorMockVirtualExecutorForObject
funcVirtualValidatorsForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber) (ra1 []insolar.Reference, err error)
inspectFuncVirtualValidatorsForObject func(ctx context.Context, objID insolar.ID, pulse insolar.PulseNumber)
afterVirtualValidatorsForObjectCounter uint64
beforeVirtualValidatorsForObjectCounter uint64
VirtualValidatorsForObjectMock mCoordinatorMockVirtualValidatorsForObject
}
// NewCoordinatorMock returns a mock for Coordinator
func NewCoordinatorMock(t minimock.Tester) *CoordinatorMock {
m := &CoordinatorMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.HeavyMock = mCoordinatorMockHeavy{mock: m}
m.HeavyMock.callArgs = []*CoordinatorMockHeavyParams{}
m.IsAuthorizedMock = mCoordinatorMockIsAuthorized{mock: m}
m.IsAuthorizedMock.callArgs = []*CoordinatorMockIsAuthorizedParams{}
m.IsBeyondLimitMock = mCoordinatorMockIsBeyondLimit{mock: m}
m.IsBeyondLimitMock.callArgs = []*CoordinatorMockIsBeyondLimitParams{}
m.IsMeAuthorizedNowMock = mCoordinatorMockIsMeAuthorizedNow{mock: m}
m.IsMeAuthorizedNowMock.callArgs = []*CoordinatorMockIsMeAuthorizedNowParams{}
m.LightExecutorForJetMock = mCoordinatorMockLightExecutorForJet{mock: m}
m.LightExecutorForJetMock.callArgs = []*CoordinatorMockLightExecutorForJetParams{}
m.LightExecutorForObjectMock = mCoordinatorMockLightExecutorForObject{mock: m}
m.LightExecutorForObjectMock.callArgs = []*CoordinatorMockLightExecutorForObjectParams{}
m.LightValidatorsForJetMock = mCoordinatorMockLightValidatorsForJet{mock: m}
m.LightValidatorsForJetMock.callArgs = []*CoordinatorMockLightValidatorsForJetParams{}
m.LightValidatorsForObjectMock = mCoordinatorMockLightValidatorsForObject{mock: m}
m.LightValidatorsForObjectMock.callArgs = []*CoordinatorMockLightValidatorsForObjectParams{}
m.MeMock = mCoordinatorMockMe{mock: m}
m.NodeForJetMock = mCoordinatorMockNodeForJet{mock: m}
m.NodeForJetMock.callArgs = []*CoordinatorMockNodeForJetParams{}
m.NodeForObjectMock = mCoordinatorMockNodeForObject{mock: m}
m.NodeForObjectMock.callArgs = []*CoordinatorMockNodeForObjectParams{}
m.QueryRoleMock = mCoordinatorMockQueryRole{mock: m}
m.QueryRoleMock.callArgs = []*CoordinatorMockQueryRoleParams{}
m.VirtualExecutorForObjectMock = mCoordinatorMockVirtualExecutorForObject{mock: m}
m.VirtualExecutorForObjectMock.callArgs = []*CoordinatorMockVirtualExecutorForObjectParams{}
m.VirtualValidatorsForObjectMock = mCoordinatorMockVirtualValidatorsForObject{mock: m}
m.VirtualValidatorsForObjectMock.callArgs = []*CoordinatorMockVirtualValidatorsForObjectParams{}
return m
}
type mCoordinatorMockHeavy struct {
mock *CoordinatorMock
defaultExpectation *CoordinatorMockHeavyExpectation
expectations []*CoordinatorMockHeavyExpectation
callArgs []*CoordinatorMockHeavyParams
mutex sync.RWMutex
}
// CoordinatorMockHeavyExpectation specifies expectation struct of the Coordinator.Heavy
type CoordinatorMockHeavyExpectation struct {
mock *CoordinatorMock
params *CoordinatorMockHeavyParams
results *CoordinatorMockHeavyResults
Counter uint64
}
// CoordinatorMockHeavyParams contains parameters of the Coordinator.Heavy
type CoordinatorMockHeavyParams struct {
ctx context.Context
}
// CoordinatorMockHeavyResults contains results of the Coordinator.Heavy
type CoordinatorMockHeavyResults struct {
rp1 *insolar.Reference
err error
}
// Expect sets up expected params for Coordinator.Heavy
func (mmHeavy *mCoordinatorMockHeavy) Expect(ctx context.Context) *mCoordinatorMockHeavy {
if mmHeavy.mock.funcHeavy != nil {
mmHeavy.mock.t.Fatalf("CoordinatorMock.Heavy mock is already set by Set")
}
if mmHeavy.defaultExpectation == nil {
mmHeavy.defaultExpectation = &CoordinatorMockHeavyExpectation{}
}
mmHeavy.defaultExpectation.params = &CoordinatorMockHeavyParams{ctx}
for _, e := range mmHeavy.expectations {
if minimock.Equal(e.params, mmHeavy.defaultExpectation.params) {
mmHeavy.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmHeavy.defaultExpectation.params)
}
}
return mmHeavy
}
// Inspect accepts an inspector function that has same arguments as the Coordinator.Heavy
func (mmHeavy *mCoordinatorMockHeavy) Inspect(f func(ctx context.Context)) *mCoordinatorMockHeavy {
if mmHeavy.mock.inspectFuncHeavy != nil {
mmHeavy.mock.t.Fatalf("Inspect function is already set for CoordinatorMock.Heavy")
}
mmHeavy.mock.inspectFuncHeavy = f
return mmHeavy
}
// Return sets up results that will be returned by Coordinator.Heavy
func (mmHeavy *mCoordinatorMockHeavy) Return(rp1 *insolar.Reference, err error) *CoordinatorMock {
if mmHeavy.mock.funcHeavy != nil {
mmHeavy.mock.t.Fatalf("CoordinatorMock.Heavy mock is already set by Set")
}
if mmHeavy.defaultExpectation == nil {
mmHeavy.defaultExpectation = &CoordinatorMockHeavyExpectation{mock: mmHeavy.mock}
}
mmHeavy.defaultExpectation.results = &CoordinatorMockHeavyResults{rp1, err}
return mmHeavy.mock
}
//Set uses given function f to mock the Coordinator.Heavy method
func (mmHeavy *mCoordinatorMockHeavy) Set(f func(ctx context.Context) (rp1 *insolar.Reference, err error)) *CoordinatorMock {
if mmHeavy.defaultExpectation != nil {
mmHeavy.mock.t.Fatalf("Default expectation is already set for the Coordinator.Heavy method")
}
if len(mmHeavy.expectations) > 0 {
mmHeavy.mock.t.Fatalf("Some expectations are already set for the Coordinator.Heavy method")
}
mmHeavy.mock.funcHeavy = f
return mmHeavy.mock
}
// When sets expectation for the Coordinator.Heavy which will trigger the result defined by the following
// Then helper
func (mmHeavy *mCoordinatorMockHeavy) When(ctx context.Context) *CoordinatorMockHeavyExpectation {
if mmHeavy.mock.funcHeavy != nil {
mmHeavy.mock.t.Fatalf("CoordinatorMock.Heavy mock is already set by Set")
}
expectation := &CoordinatorMockHeavyExpectation{
mock: mmHeavy.mock,
params: &CoordinatorMockHeavyParams{ctx},
}
mmHeavy.expectations = append(mmHeavy.expectations, expectation)
return expectation
}
// Then sets up Coordinator.Heavy return parameters for the expectation previously defined by the When method
func (e *CoordinatorMockHeavyExpectation) Then(rp1 *insolar.Reference, err error) *CoordinatorMock {
e.results = &CoordinatorMockHeavyResults{rp1, err}
return e.mock
}
// Heavy implements Coordinator
func (mmHeavy *CoordinatorMock) Heavy(ctx context.Context) (rp1 *insolar.Reference, err error) {
mm_atomic.AddUint64(&mmHeavy.beforeHeavyCounter, 1)
defer mm_atomic.AddUint64(&mmHeavy.afterHeavyCounter, 1)
if mmHeavy.inspectFuncHeavy != nil {
mmHeavy.inspectFuncHeavy(ctx)
}
params := &CoordinatorMockHeavyParams{ctx}
// Record call args
mmHeavy.HeavyMock.mutex.Lock()
mmHeavy.HeavyMock.callArgs = append(mmHeavy.HeavyMock.callArgs, params)
mmHeavy.HeavyMock.mutex.Unlock()
for _, e := range mmHeavy.HeavyMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.rp1, e.results.err
}
}
if mmHeavy.HeavyMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmHeavy.HeavyMock.defaultExpectation.Counter, 1)
want := mmHeavy.HeavyMock.defaultExpectation.params
got := CoordinatorMockHeavyParams{ctx}
if want != nil && !minimock.Equal(*want, got) {
mmHeavy.t.Errorf("CoordinatorMock.Heavy got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmHeavy.HeavyMock.defaultExpectation.results
if results == nil {
mmHeavy.t.Fatal("No results are set for the CoordinatorMock.Heavy")
}
return (*results).rp1, (*results).err
}
if mmHeavy.funcHeavy != nil {
return mmHeavy.funcHeavy(ctx)
}
mmHeavy.t.Fatalf("Unexpected call to CoordinatorMock.Heavy. %v", ctx)
return
}
// HeavyAfterCounter returns a count of finished CoordinatorMock.Heavy invocations
func (mmHeavy *CoordinatorMock) HeavyAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmHeavy.afterHeavyCounter)
}
// HeavyBeforeCounter returns a count of CoordinatorMock.Heavy invocations
func (mmHeavy *CoordinatorMock) HeavyBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmHeavy.beforeHeavyCounter)
}
// Calls returns a list of arguments used in each call to CoordinatorMock.Heavy.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmHeavy *mCoordinatorMockHeavy) Calls() []*CoordinatorMockHeavyParams {
mmHeavy.mutex.RLock()
argCopy := make([]*CoordinatorMockHeavyParams, len(mmHeavy.callArgs))
copy(argCopy, mmHeavy.callArgs)
mmHeavy.mutex.RUnlock()
return argCopy
}
// MinimockHeavyDone returns true if the count of the Heavy invocations corresponds
// the number of defined expectations
func (m *CoordinatorMock) MinimockHeavyDone() bool {
for _, e := range m.HeavyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.HeavyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterHeavyCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcHeavy != nil && mm_atomic.LoadUint64(&m.afterHeavyCounter) < 1 {
return false
}
return true
}
// MinimockHeavyInspect logs each unmet expectation
func (m *CoordinatorMock) MinimockHeavyInspect() {
for _, e := range m.HeavyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to CoordinatorMock.Heavy with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.HeavyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterHeavyCounter) < 1 {
if m.HeavyMock.defaultExpectation.params == nil {
m.t.Error("Expected call to CoordinatorMock.Heavy")
} else {
m.t.Errorf("Expected call to CoordinatorMock.Heavy with params: %#v", *m.HeavyMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcHeavy != nil && mm_atomic.LoadUint64(&m.afterHeavyCounter) < 1 {
m.t.Error("Expected call to CoordinatorMock.Heavy")
}
}
type mCoordinatorMockIsAuthorized struct {
mock *CoordinatorMock
defaultExpectation *CoordinatorMockIsAuthorizedExpectation
expectations []*CoordinatorMockIsAuthorizedExpectation
callArgs []*CoordinatorMockIsAuthorizedParams
mutex sync.RWMutex
}
// CoordinatorMockIsAuthorizedExpectation specifies expectation struct of the Coordinator.IsAuthorized
type CoordinatorMockIsAuthorizedExpectation struct {
mock *CoordinatorMock
params *CoordinatorMockIsAuthorizedParams
results *CoordinatorMockIsAuthorizedResults
Counter uint64
}
// CoordinatorMockIsAuthorizedParams contains parameters of the Coordinator.IsAuthorized
type CoordinatorMockIsAuthorizedParams struct {
ctx context.Context
role insolar.DynamicRole
obj insolar.ID
pulse insolar.PulseNumber
node insolar.Reference
}
// CoordinatorMockIsAuthorizedResults contains results of the Coordinator.IsAuthorized
type CoordinatorMockIsAuthorizedResults struct {
b1 bool
err error
}
// Expect sets up expected params for Coordinator.IsAuthorized
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) Expect(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference) *mCoordinatorMockIsAuthorized {
if mmIsAuthorized.mock.funcIsAuthorized != nil {
mmIsAuthorized.mock.t.Fatalf("CoordinatorMock.IsAuthorized mock is already set by Set")
}
if mmIsAuthorized.defaultExpectation == nil {
mmIsAuthorized.defaultExpectation = &CoordinatorMockIsAuthorizedExpectation{}
}
mmIsAuthorized.defaultExpectation.params = &CoordinatorMockIsAuthorizedParams{ctx, role, obj, pulse, node}
for _, e := range mmIsAuthorized.expectations {
if minimock.Equal(e.params, mmIsAuthorized.defaultExpectation.params) {
mmIsAuthorized.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsAuthorized.defaultExpectation.params)
}
}
return mmIsAuthorized
}
// Inspect accepts an inspector function that has same arguments as the Coordinator.IsAuthorized
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) Inspect(f func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference)) *mCoordinatorMockIsAuthorized {
if mmIsAuthorized.mock.inspectFuncIsAuthorized != nil {
mmIsAuthorized.mock.t.Fatalf("Inspect function is already set for CoordinatorMock.IsAuthorized")
}
mmIsAuthorized.mock.inspectFuncIsAuthorized = f
return mmIsAuthorized
}
// Return sets up results that will be returned by Coordinator.IsAuthorized
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) Return(b1 bool, err error) *CoordinatorMock {
if mmIsAuthorized.mock.funcIsAuthorized != nil {
mmIsAuthorized.mock.t.Fatalf("CoordinatorMock.IsAuthorized mock is already set by Set")
}
if mmIsAuthorized.defaultExpectation == nil {
mmIsAuthorized.defaultExpectation = &CoordinatorMockIsAuthorizedExpectation{mock: mmIsAuthorized.mock}
}
mmIsAuthorized.defaultExpectation.results = &CoordinatorMockIsAuthorizedResults{b1, err}
return mmIsAuthorized.mock
}
//Set uses given function f to mock the Coordinator.IsAuthorized method
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) Set(f func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference) (b1 bool, err error)) *CoordinatorMock {
if mmIsAuthorized.defaultExpectation != nil {
mmIsAuthorized.mock.t.Fatalf("Default expectation is already set for the Coordinator.IsAuthorized method")
}
if len(mmIsAuthorized.expectations) > 0 {
mmIsAuthorized.mock.t.Fatalf("Some expectations are already set for the Coordinator.IsAuthorized method")
}
mmIsAuthorized.mock.funcIsAuthorized = f
return mmIsAuthorized.mock
}
// When sets expectation for the Coordinator.IsAuthorized which will trigger the result defined by the following
// Then helper
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) When(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference) *CoordinatorMockIsAuthorizedExpectation {
if mmIsAuthorized.mock.funcIsAuthorized != nil {
mmIsAuthorized.mock.t.Fatalf("CoordinatorMock.IsAuthorized mock is already set by Set")
}
expectation := &CoordinatorMockIsAuthorizedExpectation{
mock: mmIsAuthorized.mock,
params: &CoordinatorMockIsAuthorizedParams{ctx, role, obj, pulse, node},
}
mmIsAuthorized.expectations = append(mmIsAuthorized.expectations, expectation)
return expectation
}
// Then sets up Coordinator.IsAuthorized return parameters for the expectation previously defined by the When method
func (e *CoordinatorMockIsAuthorizedExpectation) Then(b1 bool, err error) *CoordinatorMock {
e.results = &CoordinatorMockIsAuthorizedResults{b1, err}
return e.mock
}
// IsAuthorized implements Coordinator
func (mmIsAuthorized *CoordinatorMock) IsAuthorized(ctx context.Context, role insolar.DynamicRole, obj insolar.ID, pulse insolar.PulseNumber, node insolar.Reference) (b1 bool, err error) {
mm_atomic.AddUint64(&mmIsAuthorized.beforeIsAuthorizedCounter, 1)
defer mm_atomic.AddUint64(&mmIsAuthorized.afterIsAuthorizedCounter, 1)
if mmIsAuthorized.inspectFuncIsAuthorized != nil {
mmIsAuthorized.inspectFuncIsAuthorized(ctx, role, obj, pulse, node)
}
params := &CoordinatorMockIsAuthorizedParams{ctx, role, obj, pulse, node}
// Record call args
mmIsAuthorized.IsAuthorizedMock.mutex.Lock()
mmIsAuthorized.IsAuthorizedMock.callArgs = append(mmIsAuthorized.IsAuthorizedMock.callArgs, params)
mmIsAuthorized.IsAuthorizedMock.mutex.Unlock()
for _, e := range mmIsAuthorized.IsAuthorizedMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.b1, e.results.err
}
}
if mmIsAuthorized.IsAuthorizedMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmIsAuthorized.IsAuthorizedMock.defaultExpectation.Counter, 1)
want := mmIsAuthorized.IsAuthorizedMock.defaultExpectation.params
got := CoordinatorMockIsAuthorizedParams{ctx, role, obj, pulse, node}
if want != nil && !minimock.Equal(*want, got) {
mmIsAuthorized.t.Errorf("CoordinatorMock.IsAuthorized got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmIsAuthorized.IsAuthorizedMock.defaultExpectation.results
if results == nil {
mmIsAuthorized.t.Fatal("No results are set for the CoordinatorMock.IsAuthorized")
}
return (*results).b1, (*results).err
}
if mmIsAuthorized.funcIsAuthorized != nil {
return mmIsAuthorized.funcIsAuthorized(ctx, role, obj, pulse, node)
}
mmIsAuthorized.t.Fatalf("Unexpected call to CoordinatorMock.IsAuthorized. %v %v %v %v %v", ctx, role, obj, pulse, node)
return
}
// IsAuthorizedAfterCounter returns a count of finished CoordinatorMock.IsAuthorized invocations
func (mmIsAuthorized *CoordinatorMock) IsAuthorizedAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsAuthorized.afterIsAuthorizedCounter)
}
// IsAuthorizedBeforeCounter returns a count of CoordinatorMock.IsAuthorized invocations
func (mmIsAuthorized *CoordinatorMock) IsAuthorizedBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsAuthorized.beforeIsAuthorizedCounter)
}
// Calls returns a list of arguments used in each call to CoordinatorMock.IsAuthorized.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmIsAuthorized *mCoordinatorMockIsAuthorized) Calls() []*CoordinatorMockIsAuthorizedParams {
mmIsAuthorized.mutex.RLock()
argCopy := make([]*CoordinatorMockIsAuthorizedParams, len(mmIsAuthorized.callArgs))
copy(argCopy, mmIsAuthorized.callArgs)
mmIsAuthorized.mutex.RUnlock()
return argCopy
}
// MinimockIsAuthorizedDone returns true if the count of the IsAuthorized invocations corresponds
// the number of defined expectations
func (m *CoordinatorMock) MinimockIsAuthorizedDone() bool {
for _, e := range m.IsAuthorizedMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.IsAuthorizedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsAuthorizedCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcIsAuthorized != nil && mm_atomic.LoadUint64(&m.afterIsAuthorizedCounter) < 1 {
return false
}
return true
}
// MinimockIsAuthorizedInspect logs each unmet expectation
func (m *CoordinatorMock) MinimockIsAuthorizedInspect() {
for _, e := range m.IsAuthorizedMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to CoordinatorMock.IsAuthorized with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.IsAuthorizedMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsAuthorizedCounter) < 1 {
if m.IsAuthorizedMock.defaultExpectation.params == nil {
m.t.Error("Expected call to CoordinatorMock.IsAuthorized")
} else {
m.t.Errorf("Expected call to CoordinatorMock.IsAuthorized with params: %#v", *m.IsAuthorizedMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcIsAuthorized != nil && mm_atomic.LoadUint64(&m.afterIsAuthorizedCounter) < 1 {
m.t.Error("Expected call to CoordinatorMock.IsAuthorized")
}
}
type mCoordinatorMockIsBeyondLimit struct {
mock *CoordinatorMock
defaultExpectation *CoordinatorMockIsBeyondLimitExpectation
expectations []*CoordinatorMockIsBeyondLimitExpectation
callArgs []*CoordinatorMockIsBeyondLimitParams
mutex sync.RWMutex
}
// CoordinatorMockIsBeyondLimitExpectation specifies expectation struct of the Coordinator.IsBeyondLimit
type CoordinatorMockIsBeyondLimitExpectation struct {
mock *CoordinatorMock
params *CoordinatorMockIsBeyondLimitParams
results *CoordinatorMockIsBeyondLimitResults
Counter uint64
}
// CoordinatorMockIsBeyondLimitParams contains parameters of the Coordinator.IsBeyondLimit
type CoordinatorMockIsBeyondLimitParams struct {
ctx context.Context
targetPN insolar.PulseNumber
}
// CoordinatorMockIsBeyondLimitResults contains results of the Coordinator.IsBeyondLimit
type CoordinatorMockIsBeyondLimitResults struct {
b1 bool
err error
}
// Expect sets up expected params for Coordinator.IsBeyondLimit
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) Expect(ctx context.Context, targetPN insolar.PulseNumber) *mCoordinatorMockIsBeyondLimit {
if mmIsBeyondLimit.mock.funcIsBeyondLimit != nil {
mmIsBeyondLimit.mock.t.Fatalf("CoordinatorMock.IsBeyondLimit mock is already set by Set")
}
if mmIsBeyondLimit.defaultExpectation == nil {
mmIsBeyondLimit.defaultExpectation = &CoordinatorMockIsBeyondLimitExpectation{}
}
mmIsBeyondLimit.defaultExpectation.params = &CoordinatorMockIsBeyondLimitParams{ctx, targetPN}
for _, e := range mmIsBeyondLimit.expectations {
if minimock.Equal(e.params, mmIsBeyondLimit.defaultExpectation.params) {
mmIsBeyondLimit.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsBeyondLimit.defaultExpectation.params)
}
}
return mmIsBeyondLimit
}
// Inspect accepts an inspector function that has same arguments as the Coordinator.IsBeyondLimit
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) Inspect(f func(ctx context.Context, targetPN insolar.PulseNumber)) *mCoordinatorMockIsBeyondLimit {
if mmIsBeyondLimit.mock.inspectFuncIsBeyondLimit != nil {
mmIsBeyondLimit.mock.t.Fatalf("Inspect function is already set for CoordinatorMock.IsBeyondLimit")
}
mmIsBeyondLimit.mock.inspectFuncIsBeyondLimit = f
return mmIsBeyondLimit
}
// Return sets up results that will be returned by Coordinator.IsBeyondLimit
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) Return(b1 bool, err error) *CoordinatorMock {
if mmIsBeyondLimit.mock.funcIsBeyondLimit != nil {
mmIsBeyondLimit.mock.t.Fatalf("CoordinatorMock.IsBeyondLimit mock is already set by Set")
}
if mmIsBeyondLimit.defaultExpectation == nil {
mmIsBeyondLimit.defaultExpectation = &CoordinatorMockIsBeyondLimitExpectation{mock: mmIsBeyondLimit.mock}
}
mmIsBeyondLimit.defaultExpectation.results = &CoordinatorMockIsBeyondLimitResults{b1, err}
return mmIsBeyondLimit.mock
}
//Set uses given function f to mock the Coordinator.IsBeyondLimit method
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) Set(f func(ctx context.Context, targetPN insolar.PulseNumber) (b1 bool, err error)) *CoordinatorMock {
if mmIsBeyondLimit.defaultExpectation != nil {
mmIsBeyondLimit.mock.t.Fatalf("Default expectation is already set for the Coordinator.IsBeyondLimit method")
}
if len(mmIsBeyondLimit.expectations) > 0 {
mmIsBeyondLimit.mock.t.Fatalf("Some expectations are already set for the Coordinator.IsBeyondLimit method")
}
mmIsBeyondLimit.mock.funcIsBeyondLimit = f
return mmIsBeyondLimit.mock
}
// When sets expectation for the Coordinator.IsBeyondLimit which will trigger the result defined by the following
// Then helper
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) When(ctx context.Context, targetPN insolar.PulseNumber) *CoordinatorMockIsBeyondLimitExpectation {
if mmIsBeyondLimit.mock.funcIsBeyondLimit != nil {
mmIsBeyondLimit.mock.t.Fatalf("CoordinatorMock.IsBeyondLimit mock is already set by Set")
}
expectation := &CoordinatorMockIsBeyondLimitExpectation{
mock: mmIsBeyondLimit.mock,
params: &CoordinatorMockIsBeyondLimitParams{ctx, targetPN},
}
mmIsBeyondLimit.expectations = append(mmIsBeyondLimit.expectations, expectation)
return expectation
}
// Then sets up Coordinator.IsBeyondLimit return parameters for the expectation previously defined by the When method
func (e *CoordinatorMockIsBeyondLimitExpectation) Then(b1 bool, err error) *CoordinatorMock {
e.results = &CoordinatorMockIsBeyondLimitResults{b1, err}
return e.mock
}
// IsBeyondLimit implements Coordinator
func (mmIsBeyondLimit *CoordinatorMock) IsBeyondLimit(ctx context.Context, targetPN insolar.PulseNumber) (b1 bool, err error) {
mm_atomic.AddUint64(&mmIsBeyondLimit.beforeIsBeyondLimitCounter, 1)
defer mm_atomic.AddUint64(&mmIsBeyondLimit.afterIsBeyondLimitCounter, 1)
if mmIsBeyondLimit.inspectFuncIsBeyondLimit != nil {
mmIsBeyondLimit.inspectFuncIsBeyondLimit(ctx, targetPN)
}
params := &CoordinatorMockIsBeyondLimitParams{ctx, targetPN}
// Record call args
mmIsBeyondLimit.IsBeyondLimitMock.mutex.Lock()
mmIsBeyondLimit.IsBeyondLimitMock.callArgs = append(mmIsBeyondLimit.IsBeyondLimitMock.callArgs, params)
mmIsBeyondLimit.IsBeyondLimitMock.mutex.Unlock()
for _, e := range mmIsBeyondLimit.IsBeyondLimitMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.b1, e.results.err
}
}
if mmIsBeyondLimit.IsBeyondLimitMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmIsBeyondLimit.IsBeyondLimitMock.defaultExpectation.Counter, 1)
want := mmIsBeyondLimit.IsBeyondLimitMock.defaultExpectation.params
got := CoordinatorMockIsBeyondLimitParams{ctx, targetPN}
if want != nil && !minimock.Equal(*want, got) {
mmIsBeyondLimit.t.Errorf("CoordinatorMock.IsBeyondLimit got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmIsBeyondLimit.IsBeyondLimitMock.defaultExpectation.results
if results == nil {
mmIsBeyondLimit.t.Fatal("No results are set for the CoordinatorMock.IsBeyondLimit")
}
return (*results).b1, (*results).err
}
if mmIsBeyondLimit.funcIsBeyondLimit != nil {
return mmIsBeyondLimit.funcIsBeyondLimit(ctx, targetPN)
}
mmIsBeyondLimit.t.Fatalf("Unexpected call to CoordinatorMock.IsBeyondLimit. %v %v", ctx, targetPN)
return
}
// IsBeyondLimitAfterCounter returns a count of finished CoordinatorMock.IsBeyondLimit invocations
func (mmIsBeyondLimit *CoordinatorMock) IsBeyondLimitAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsBeyondLimit.afterIsBeyondLimitCounter)
}
// IsBeyondLimitBeforeCounter returns a count of CoordinatorMock.IsBeyondLimit invocations
func (mmIsBeyondLimit *CoordinatorMock) IsBeyondLimitBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsBeyondLimit.beforeIsBeyondLimitCounter)
}
// Calls returns a list of arguments used in each call to CoordinatorMock.IsBeyondLimit.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmIsBeyondLimit *mCoordinatorMockIsBeyondLimit) Calls() []*CoordinatorMockIsBeyondLimitParams {
mmIsBeyondLimit.mutex.RLock()
argCopy := make([]*CoordinatorMockIsBeyondLimitParams, len(mmIsBeyondLimit.callArgs))
copy(argCopy, mmIsBeyondLimit.callArgs)
mmIsBeyondLimit.mutex.RUnlock()
return argCopy
}
// MinimockIsBeyondLimitDone returns true if the count of the IsBeyondLimit invocations corresponds
// the number of defined expectations
func (m *CoordinatorMock) MinimockIsBeyondLimitDone() bool {
for _, e := range m.IsBeyondLimitMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.IsBeyondLimitMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsBeyondLimitCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcIsBeyondLimit != nil && mm_atomic.LoadUint64(&m.afterIsBeyondLimitCounter) < 1 {
return false
}
return true
}
// MinimockIsBeyondLimitInspect logs each unmet expectation
func (m *CoordinatorMock) MinimockIsBeyondLimitInspect() {
for _, e := range m.IsBeyondLimitMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to CoordinatorMock.IsBeyondLimit with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.IsBeyondLimitMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsBeyondLimitCounter) < 1 {
if m.IsBeyondLimitMock.defaultExpectation.params == nil {
m.t.Error("Expected call to CoordinatorMock.IsBeyondLimit")
} else {
m.t.Errorf("Expected call to CoordinatorMock.IsBeyondLimit with params: %#v", *m.IsBeyondLimitMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcIsBeyondLimit != nil && mm_atomic.LoadUint64(&m.afterIsBeyondLimitCounter) < 1 {
m.t.Error("Expected call to CoordinatorMock.IsBeyondLimit")
}
}
type mCoordinatorMockIsMeAuthorizedNow struct {
mock *CoordinatorMock
defaultExpectation *CoordinatorMockIsMeAuthorizedNowExpectation
expectations []*CoordinatorMockIsMeAuthorizedNowExpectation
callArgs []*CoordinatorMockIsMeAuthorizedNowParams
mutex sync.RWMutex
}
// CoordinatorMockIsMeAuthorizedNowExpectation specifies expectation struct of the Coordinator.IsMeAuthorizedNow
type CoordinatorMockIsMeAuthorizedNowExpectation struct {
mock *CoordinatorMock
params *CoordinatorMockIsMeAuthorizedNowParams
results *CoordinatorMockIsMeAuthorizedNowResults
Counter uint64
}
// CoordinatorMockIsMeAuthorizedNowParams contains parameters of the Coordinator.IsMeAuthorizedNow
type CoordinatorMockIsMeAuthorizedNowParams struct {
ctx context.Context
role insolar.DynamicRole
obj insolar.ID
}
// CoordinatorMockIsMeAuthorizedNowResults contains results of the Coordinator.IsMeAuthorizedNow
type CoordinatorMockIsMeAuthorizedNowResults struct {
b1 bool
err error
}
// Expect sets up expected params for Coordinator.IsMeAuthorizedNow
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) Expect(ctx context.Context, role insolar.DynamicRole, obj insolar.ID) *mCoordinatorMockIsMeAuthorizedNow {
if mmIsMeAuthorizedNow.mock.funcIsMeAuthorizedNow != nil {
mmIsMeAuthorizedNow.mock.t.Fatalf("CoordinatorMock.IsMeAuthorizedNow mock is already set by Set")
}
if mmIsMeAuthorizedNow.defaultExpectation == nil {
mmIsMeAuthorizedNow.defaultExpectation = &CoordinatorMockIsMeAuthorizedNowExpectation{}
}
mmIsMeAuthorizedNow.defaultExpectation.params = &CoordinatorMockIsMeAuthorizedNowParams{ctx, role, obj}
for _, e := range mmIsMeAuthorizedNow.expectations {
if minimock.Equal(e.params, mmIsMeAuthorizedNow.defaultExpectation.params) {
mmIsMeAuthorizedNow.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmIsMeAuthorizedNow.defaultExpectation.params)
}
}
return mmIsMeAuthorizedNow
}
// Inspect accepts an inspector function that has same arguments as the Coordinator.IsMeAuthorizedNow
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) Inspect(f func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID)) *mCoordinatorMockIsMeAuthorizedNow {
if mmIsMeAuthorizedNow.mock.inspectFuncIsMeAuthorizedNow != nil {
mmIsMeAuthorizedNow.mock.t.Fatalf("Inspect function is already set for CoordinatorMock.IsMeAuthorizedNow")
}
mmIsMeAuthorizedNow.mock.inspectFuncIsMeAuthorizedNow = f
return mmIsMeAuthorizedNow
}
// Return sets up results that will be returned by Coordinator.IsMeAuthorizedNow
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) Return(b1 bool, err error) *CoordinatorMock {
if mmIsMeAuthorizedNow.mock.funcIsMeAuthorizedNow != nil {
mmIsMeAuthorizedNow.mock.t.Fatalf("CoordinatorMock.IsMeAuthorizedNow mock is already set by Set")
}
if mmIsMeAuthorizedNow.defaultExpectation == nil {
mmIsMeAuthorizedNow.defaultExpectation = &CoordinatorMockIsMeAuthorizedNowExpectation{mock: mmIsMeAuthorizedNow.mock}
}
mmIsMeAuthorizedNow.defaultExpectation.results = &CoordinatorMockIsMeAuthorizedNowResults{b1, err}
return mmIsMeAuthorizedNow.mock
}
//Set uses given function f to mock the Coordinator.IsMeAuthorizedNow method
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) Set(f func(ctx context.Context, role insolar.DynamicRole, obj insolar.ID) (b1 bool, err error)) *CoordinatorMock {
if mmIsMeAuthorizedNow.defaultExpectation != nil {
mmIsMeAuthorizedNow.mock.t.Fatalf("Default expectation is already set for the Coordinator.IsMeAuthorizedNow method")
}
if len(mmIsMeAuthorizedNow.expectations) > 0 {
mmIsMeAuthorizedNow.mock.t.Fatalf("Some expectations are already set for the Coordinator.IsMeAuthorizedNow method")
}
mmIsMeAuthorizedNow.mock.funcIsMeAuthorizedNow = f
return mmIsMeAuthorizedNow.mock
}
// When sets expectation for the Coordinator.IsMeAuthorizedNow which will trigger the result defined by the following
// Then helper
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) When(ctx context.Context, role insolar.DynamicRole, obj insolar.ID) *CoordinatorMockIsMeAuthorizedNowExpectation {
if mmIsMeAuthorizedNow.mock.funcIsMeAuthorizedNow != nil {
mmIsMeAuthorizedNow.mock.t.Fatalf("CoordinatorMock.IsMeAuthorizedNow mock is already set by Set")
}
expectation := &CoordinatorMockIsMeAuthorizedNowExpectation{
mock: mmIsMeAuthorizedNow.mock,
params: &CoordinatorMockIsMeAuthorizedNowParams{ctx, role, obj},
}
mmIsMeAuthorizedNow.expectations = append(mmIsMeAuthorizedNow.expectations, expectation)
return expectation
}
// Then sets up Coordinator.IsMeAuthorizedNow return parameters for the expectation previously defined by the When method
func (e *CoordinatorMockIsMeAuthorizedNowExpectation) Then(b1 bool, err error) *CoordinatorMock {
e.results = &CoordinatorMockIsMeAuthorizedNowResults{b1, err}
return e.mock
}
// IsMeAuthorizedNow implements Coordinator
func (mmIsMeAuthorizedNow *CoordinatorMock) IsMeAuthorizedNow(ctx context.Context, role insolar.DynamicRole, obj insolar.ID) (b1 bool, err error) {
mm_atomic.AddUint64(&mmIsMeAuthorizedNow.beforeIsMeAuthorizedNowCounter, 1)
defer mm_atomic.AddUint64(&mmIsMeAuthorizedNow.afterIsMeAuthorizedNowCounter, 1)
if mmIsMeAuthorizedNow.inspectFuncIsMeAuthorizedNow != nil {
mmIsMeAuthorizedNow.inspectFuncIsMeAuthorizedNow(ctx, role, obj)
}
params := &CoordinatorMockIsMeAuthorizedNowParams{ctx, role, obj}
// Record call args
mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.mutex.Lock()
mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.callArgs = append(mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.callArgs, params)
mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.mutex.Unlock()
for _, e := range mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.b1, e.results.err
}
}
if mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.defaultExpectation.Counter, 1)
want := mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.defaultExpectation.params
got := CoordinatorMockIsMeAuthorizedNowParams{ctx, role, obj}
if want != nil && !minimock.Equal(*want, got) {
mmIsMeAuthorizedNow.t.Errorf("CoordinatorMock.IsMeAuthorizedNow got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmIsMeAuthorizedNow.IsMeAuthorizedNowMock.defaultExpectation.results
if results == nil {
mmIsMeAuthorizedNow.t.Fatal("No results are set for the CoordinatorMock.IsMeAuthorizedNow")
}
return (*results).b1, (*results).err
}
if mmIsMeAuthorizedNow.funcIsMeAuthorizedNow != nil {
return mmIsMeAuthorizedNow.funcIsMeAuthorizedNow(ctx, role, obj)
}
mmIsMeAuthorizedNow.t.Fatalf("Unexpected call to CoordinatorMock.IsMeAuthorizedNow. %v %v %v", ctx, role, obj)
return
}
// IsMeAuthorizedNowAfterCounter returns a count of finished CoordinatorMock.IsMeAuthorizedNow invocations
func (mmIsMeAuthorizedNow *CoordinatorMock) IsMeAuthorizedNowAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsMeAuthorizedNow.afterIsMeAuthorizedNowCounter)
}
// IsMeAuthorizedNowBeforeCounter returns a count of CoordinatorMock.IsMeAuthorizedNow invocations
func (mmIsMeAuthorizedNow *CoordinatorMock) IsMeAuthorizedNowBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmIsMeAuthorizedNow.beforeIsMeAuthorizedNowCounter)
}
// Calls returns a list of arguments used in each call to CoordinatorMock.IsMeAuthorizedNow.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmIsMeAuthorizedNow *mCoordinatorMockIsMeAuthorizedNow) Calls() []*CoordinatorMockIsMeAuthorizedNowParams {
mmIsMeAuthorizedNow.mutex.RLock()
argCopy := make([]*CoordinatorMockIsMeAuthorizedNowParams, len(mmIsMeAuthorizedNow.callArgs))
copy(argCopy, mmIsMeAuthorizedNow.callArgs)
mmIsMeAuthorizedNow.mutex.RUnlock()
return argCopy
}
// MinimockIsMeAuthorizedNowDone returns true if the count of the IsMeAuthorizedNow invocations corresponds
// the number of defined expectations
func (m *CoordinatorMock) MinimockIsMeAuthorizedNowDone() bool {
for _, e := range m.IsMeAuthorizedNowMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
return false
}
}
// if default expectation was set then invocations count should be greater than zero
if m.IsMeAuthorizedNowMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterIsMeAuthorizedNowCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcIsMeAuthorizedNow != nil && mm_atomic.LoadUint64(&m.afterIsMeAuthorizedNowCounter) < 1 {
return false
}