-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_descriptor_mock.go
1526 lines (1180 loc) · 44 KB
/
object_descriptor_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 testutils
/*
DO NOT EDIT!
This code was generated automatically using github.com/gojuno/minimock v1.9
The original interface "ObjectDescriptor" can be found in github.com/insolar/insolar/core
*/
import (
"sync/atomic"
"time"
"github.com/gojuno/minimock"
core "github.com/insolar/insolar/core"
testify_assert "github.com/stretchr/testify/assert"
)
//ObjectDescriptorMock implements github.com/insolar/insolar/core.ObjectDescriptor
type ObjectDescriptorMock struct {
t minimock.Tester
ChildPointerFunc func() (r *core.RecordID)
ChildPointerCounter uint64
ChildPointerPreCounter uint64
ChildPointerMock mObjectDescriptorMockChildPointer
ChildrenFunc func(p *core.PulseNumber) (r core.RefIterator, r1 error)
ChildrenCounter uint64
ChildrenPreCounter uint64
ChildrenMock mObjectDescriptorMockChildren
CodeFunc func() (r *core.RecordRef, r1 error)
CodeCounter uint64
CodePreCounter uint64
CodeMock mObjectDescriptorMockCode
HeadRefFunc func() (r *core.RecordRef)
HeadRefCounter uint64
HeadRefPreCounter uint64
HeadRefMock mObjectDescriptorMockHeadRef
IsPrototypeFunc func() (r bool)
IsPrototypeCounter uint64
IsPrototypePreCounter uint64
IsPrototypeMock mObjectDescriptorMockIsPrototype
MemoryFunc func() (r []byte)
MemoryCounter uint64
MemoryPreCounter uint64
MemoryMock mObjectDescriptorMockMemory
ParentFunc func() (r *core.RecordRef)
ParentCounter uint64
ParentPreCounter uint64
ParentMock mObjectDescriptorMockParent
PrototypeFunc func() (r *core.RecordRef, r1 error)
PrototypeCounter uint64
PrototypePreCounter uint64
PrototypeMock mObjectDescriptorMockPrototype
StateIDFunc func() (r *core.RecordID)
StateIDCounter uint64
StateIDPreCounter uint64
StateIDMock mObjectDescriptorMockStateID
}
//NewObjectDescriptorMock returns a mock for github.com/insolar/insolar/core.ObjectDescriptor
func NewObjectDescriptorMock(t minimock.Tester) *ObjectDescriptorMock {
m := &ObjectDescriptorMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.ChildPointerMock = mObjectDescriptorMockChildPointer{mock: m}
m.ChildrenMock = mObjectDescriptorMockChildren{mock: m}
m.CodeMock = mObjectDescriptorMockCode{mock: m}
m.HeadRefMock = mObjectDescriptorMockHeadRef{mock: m}
m.IsPrototypeMock = mObjectDescriptorMockIsPrototype{mock: m}
m.MemoryMock = mObjectDescriptorMockMemory{mock: m}
m.ParentMock = mObjectDescriptorMockParent{mock: m}
m.PrototypeMock = mObjectDescriptorMockPrototype{mock: m}
m.StateIDMock = mObjectDescriptorMockStateID{mock: m}
return m
}
type mObjectDescriptorMockChildPointer struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockChildPointerExpectation
expectationSeries []*ObjectDescriptorMockChildPointerExpectation
}
type ObjectDescriptorMockChildPointerExpectation struct {
result *ObjectDescriptorMockChildPointerResult
}
type ObjectDescriptorMockChildPointerResult struct {
r *core.RecordID
}
//Expect specifies that invocation of ObjectDescriptor.ChildPointer is expected from 1 to Infinity times
func (m *mObjectDescriptorMockChildPointer) Expect() *mObjectDescriptorMockChildPointer {
m.mock.ChildPointerFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockChildPointerExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.ChildPointer
func (m *mObjectDescriptorMockChildPointer) Return(r *core.RecordID) *ObjectDescriptorMock {
m.mock.ChildPointerFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockChildPointerExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockChildPointerResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.ChildPointer is expected once
func (m *mObjectDescriptorMockChildPointer) ExpectOnce() *ObjectDescriptorMockChildPointerExpectation {
m.mock.ChildPointerFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockChildPointerExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockChildPointerExpectation) Return(r *core.RecordID) {
e.result = &ObjectDescriptorMockChildPointerResult{r}
}
//Set uses given function f as a mock of ObjectDescriptor.ChildPointer method
func (m *mObjectDescriptorMockChildPointer) Set(f func() (r *core.RecordID)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ChildPointerFunc = f
return m.mock
}
//ChildPointer implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) ChildPointer() (r *core.RecordID) {
counter := atomic.AddUint64(&m.ChildPointerPreCounter, 1)
defer atomic.AddUint64(&m.ChildPointerCounter, 1)
if len(m.ChildPointerMock.expectationSeries) > 0 {
if counter > uint64(len(m.ChildPointerMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.ChildPointer.")
return
}
result := m.ChildPointerMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.ChildPointer")
return
}
r = result.r
return
}
if m.ChildPointerMock.mainExpectation != nil {
result := m.ChildPointerMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.ChildPointer")
}
r = result.r
return
}
if m.ChildPointerFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.ChildPointer.")
return
}
return m.ChildPointerFunc()
}
//ChildPointerMinimockCounter returns a count of ObjectDescriptorMock.ChildPointerFunc invocations
func (m *ObjectDescriptorMock) ChildPointerMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ChildPointerCounter)
}
//ChildPointerMinimockPreCounter returns the value of ObjectDescriptorMock.ChildPointer invocations
func (m *ObjectDescriptorMock) ChildPointerMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ChildPointerPreCounter)
}
//ChildPointerFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) ChildPointerFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ChildPointerMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ChildPointerCounter) == uint64(len(m.ChildPointerMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ChildPointerMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ChildPointerCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ChildPointerFunc != nil {
return atomic.LoadUint64(&m.ChildPointerCounter) > 0
}
return true
}
type mObjectDescriptorMockChildren struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockChildrenExpectation
expectationSeries []*ObjectDescriptorMockChildrenExpectation
}
type ObjectDescriptorMockChildrenExpectation struct {
input *ObjectDescriptorMockChildrenInput
result *ObjectDescriptorMockChildrenResult
}
type ObjectDescriptorMockChildrenInput struct {
p *core.PulseNumber
}
type ObjectDescriptorMockChildrenResult struct {
r core.RefIterator
r1 error
}
//Expect specifies that invocation of ObjectDescriptor.Children is expected from 1 to Infinity times
func (m *mObjectDescriptorMockChildren) Expect(p *core.PulseNumber) *mObjectDescriptorMockChildren {
m.mock.ChildrenFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockChildrenExpectation{}
}
m.mainExpectation.input = &ObjectDescriptorMockChildrenInput{p}
return m
}
//Return specifies results of invocation of ObjectDescriptor.Children
func (m *mObjectDescriptorMockChildren) Return(r core.RefIterator, r1 error) *ObjectDescriptorMock {
m.mock.ChildrenFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockChildrenExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockChildrenResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.Children is expected once
func (m *mObjectDescriptorMockChildren) ExpectOnce(p *core.PulseNumber) *ObjectDescriptorMockChildrenExpectation {
m.mock.ChildrenFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockChildrenExpectation{}
expectation.input = &ObjectDescriptorMockChildrenInput{p}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockChildrenExpectation) Return(r core.RefIterator, r1 error) {
e.result = &ObjectDescriptorMockChildrenResult{r, r1}
}
//Set uses given function f as a mock of ObjectDescriptor.Children method
func (m *mObjectDescriptorMockChildren) Set(f func(p *core.PulseNumber) (r core.RefIterator, r1 error)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ChildrenFunc = f
return m.mock
}
//Children implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) Children(p *core.PulseNumber) (r core.RefIterator, r1 error) {
counter := atomic.AddUint64(&m.ChildrenPreCounter, 1)
defer atomic.AddUint64(&m.ChildrenCounter, 1)
if len(m.ChildrenMock.expectationSeries) > 0 {
if counter > uint64(len(m.ChildrenMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Children. %v", p)
return
}
input := m.ChildrenMock.expectationSeries[counter-1].input
testify_assert.Equal(m.t, *input, ObjectDescriptorMockChildrenInput{p}, "ObjectDescriptor.Children got unexpected parameters")
result := m.ChildrenMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Children")
return
}
r = result.r
r1 = result.r1
return
}
if m.ChildrenMock.mainExpectation != nil {
input := m.ChildrenMock.mainExpectation.input
if input != nil {
testify_assert.Equal(m.t, *input, ObjectDescriptorMockChildrenInput{p}, "ObjectDescriptor.Children got unexpected parameters")
}
result := m.ChildrenMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Children")
}
r = result.r
r1 = result.r1
return
}
if m.ChildrenFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Children. %v", p)
return
}
return m.ChildrenFunc(p)
}
//ChildrenMinimockCounter returns a count of ObjectDescriptorMock.ChildrenFunc invocations
func (m *ObjectDescriptorMock) ChildrenMinimockCounter() uint64 {
return atomic.LoadUint64(&m.ChildrenCounter)
}
//ChildrenMinimockPreCounter returns the value of ObjectDescriptorMock.Children invocations
func (m *ObjectDescriptorMock) ChildrenMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.ChildrenPreCounter)
}
//ChildrenFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) ChildrenFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.ChildrenMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.ChildrenCounter) == uint64(len(m.ChildrenMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.ChildrenMock.mainExpectation != nil {
return atomic.LoadUint64(&m.ChildrenCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.ChildrenFunc != nil {
return atomic.LoadUint64(&m.ChildrenCounter) > 0
}
return true
}
type mObjectDescriptorMockCode struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockCodeExpectation
expectationSeries []*ObjectDescriptorMockCodeExpectation
}
type ObjectDescriptorMockCodeExpectation struct {
result *ObjectDescriptorMockCodeResult
}
type ObjectDescriptorMockCodeResult struct {
r *core.RecordRef
r1 error
}
//Expect specifies that invocation of ObjectDescriptor.Code is expected from 1 to Infinity times
func (m *mObjectDescriptorMockCode) Expect() *mObjectDescriptorMockCode {
m.mock.CodeFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockCodeExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.Code
func (m *mObjectDescriptorMockCode) Return(r *core.RecordRef, r1 error) *ObjectDescriptorMock {
m.mock.CodeFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockCodeExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockCodeResult{r, r1}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.Code is expected once
func (m *mObjectDescriptorMockCode) ExpectOnce() *ObjectDescriptorMockCodeExpectation {
m.mock.CodeFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockCodeExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockCodeExpectation) Return(r *core.RecordRef, r1 error) {
e.result = &ObjectDescriptorMockCodeResult{r, r1}
}
//Set uses given function f as a mock of ObjectDescriptor.Code method
func (m *mObjectDescriptorMockCode) Set(f func() (r *core.RecordRef, r1 error)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.CodeFunc = f
return m.mock
}
//Code implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) Code() (r *core.RecordRef, r1 error) {
counter := atomic.AddUint64(&m.CodePreCounter, 1)
defer atomic.AddUint64(&m.CodeCounter, 1)
if len(m.CodeMock.expectationSeries) > 0 {
if counter > uint64(len(m.CodeMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Code.")
return
}
result := m.CodeMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Code")
return
}
r = result.r
r1 = result.r1
return
}
if m.CodeMock.mainExpectation != nil {
result := m.CodeMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Code")
}
r = result.r
r1 = result.r1
return
}
if m.CodeFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Code.")
return
}
return m.CodeFunc()
}
//CodeMinimockCounter returns a count of ObjectDescriptorMock.CodeFunc invocations
func (m *ObjectDescriptorMock) CodeMinimockCounter() uint64 {
return atomic.LoadUint64(&m.CodeCounter)
}
//CodeMinimockPreCounter returns the value of ObjectDescriptorMock.Code invocations
func (m *ObjectDescriptorMock) CodeMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.CodePreCounter)
}
//CodeFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) CodeFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.CodeMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.CodeCounter) == uint64(len(m.CodeMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.CodeMock.mainExpectation != nil {
return atomic.LoadUint64(&m.CodeCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.CodeFunc != nil {
return atomic.LoadUint64(&m.CodeCounter) > 0
}
return true
}
type mObjectDescriptorMockHeadRef struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockHeadRefExpectation
expectationSeries []*ObjectDescriptorMockHeadRefExpectation
}
type ObjectDescriptorMockHeadRefExpectation struct {
result *ObjectDescriptorMockHeadRefResult
}
type ObjectDescriptorMockHeadRefResult struct {
r *core.RecordRef
}
//Expect specifies that invocation of ObjectDescriptor.HeadRef is expected from 1 to Infinity times
func (m *mObjectDescriptorMockHeadRef) Expect() *mObjectDescriptorMockHeadRef {
m.mock.HeadRefFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockHeadRefExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.HeadRef
func (m *mObjectDescriptorMockHeadRef) Return(r *core.RecordRef) *ObjectDescriptorMock {
m.mock.HeadRefFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockHeadRefExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockHeadRefResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.HeadRef is expected once
func (m *mObjectDescriptorMockHeadRef) ExpectOnce() *ObjectDescriptorMockHeadRefExpectation {
m.mock.HeadRefFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockHeadRefExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockHeadRefExpectation) Return(r *core.RecordRef) {
e.result = &ObjectDescriptorMockHeadRefResult{r}
}
//Set uses given function f as a mock of ObjectDescriptor.HeadRef method
func (m *mObjectDescriptorMockHeadRef) Set(f func() (r *core.RecordRef)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.HeadRefFunc = f
return m.mock
}
//HeadRef implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) HeadRef() (r *core.RecordRef) {
counter := atomic.AddUint64(&m.HeadRefPreCounter, 1)
defer atomic.AddUint64(&m.HeadRefCounter, 1)
if len(m.HeadRefMock.expectationSeries) > 0 {
if counter > uint64(len(m.HeadRefMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.HeadRef.")
return
}
result := m.HeadRefMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.HeadRef")
return
}
r = result.r
return
}
if m.HeadRefMock.mainExpectation != nil {
result := m.HeadRefMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.HeadRef")
}
r = result.r
return
}
if m.HeadRefFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.HeadRef.")
return
}
return m.HeadRefFunc()
}
//HeadRefMinimockCounter returns a count of ObjectDescriptorMock.HeadRefFunc invocations
func (m *ObjectDescriptorMock) HeadRefMinimockCounter() uint64 {
return atomic.LoadUint64(&m.HeadRefCounter)
}
//HeadRefMinimockPreCounter returns the value of ObjectDescriptorMock.HeadRef invocations
func (m *ObjectDescriptorMock) HeadRefMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.HeadRefPreCounter)
}
//HeadRefFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) HeadRefFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.HeadRefMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.HeadRefCounter) == uint64(len(m.HeadRefMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.HeadRefMock.mainExpectation != nil {
return atomic.LoadUint64(&m.HeadRefCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.HeadRefFunc != nil {
return atomic.LoadUint64(&m.HeadRefCounter) > 0
}
return true
}
type mObjectDescriptorMockIsPrototype struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockIsPrototypeExpectation
expectationSeries []*ObjectDescriptorMockIsPrototypeExpectation
}
type ObjectDescriptorMockIsPrototypeExpectation struct {
result *ObjectDescriptorMockIsPrototypeResult
}
type ObjectDescriptorMockIsPrototypeResult struct {
r bool
}
//Expect specifies that invocation of ObjectDescriptor.IsPrototype is expected from 1 to Infinity times
func (m *mObjectDescriptorMockIsPrototype) Expect() *mObjectDescriptorMockIsPrototype {
m.mock.IsPrototypeFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockIsPrototypeExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.IsPrototype
func (m *mObjectDescriptorMockIsPrototype) Return(r bool) *ObjectDescriptorMock {
m.mock.IsPrototypeFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockIsPrototypeExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockIsPrototypeResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.IsPrototype is expected once
func (m *mObjectDescriptorMockIsPrototype) ExpectOnce() *ObjectDescriptorMockIsPrototypeExpectation {
m.mock.IsPrototypeFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockIsPrototypeExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockIsPrototypeExpectation) Return(r bool) {
e.result = &ObjectDescriptorMockIsPrototypeResult{r}
}
//Set uses given function f as a mock of ObjectDescriptor.IsPrototype method
func (m *mObjectDescriptorMockIsPrototype) Set(f func() (r bool)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.IsPrototypeFunc = f
return m.mock
}
//IsPrototype implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) IsPrototype() (r bool) {
counter := atomic.AddUint64(&m.IsPrototypePreCounter, 1)
defer atomic.AddUint64(&m.IsPrototypeCounter, 1)
if len(m.IsPrototypeMock.expectationSeries) > 0 {
if counter > uint64(len(m.IsPrototypeMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.IsPrototype.")
return
}
result := m.IsPrototypeMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.IsPrototype")
return
}
r = result.r
return
}
if m.IsPrototypeMock.mainExpectation != nil {
result := m.IsPrototypeMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.IsPrototype")
}
r = result.r
return
}
if m.IsPrototypeFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.IsPrototype.")
return
}
return m.IsPrototypeFunc()
}
//IsPrototypeMinimockCounter returns a count of ObjectDescriptorMock.IsPrototypeFunc invocations
func (m *ObjectDescriptorMock) IsPrototypeMinimockCounter() uint64 {
return atomic.LoadUint64(&m.IsPrototypeCounter)
}
//IsPrototypeMinimockPreCounter returns the value of ObjectDescriptorMock.IsPrototype invocations
func (m *ObjectDescriptorMock) IsPrototypeMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.IsPrototypePreCounter)
}
//IsPrototypeFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) IsPrototypeFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.IsPrototypeMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.IsPrototypeCounter) == uint64(len(m.IsPrototypeMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.IsPrototypeMock.mainExpectation != nil {
return atomic.LoadUint64(&m.IsPrototypeCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.IsPrototypeFunc != nil {
return atomic.LoadUint64(&m.IsPrototypeCounter) > 0
}
return true
}
type mObjectDescriptorMockMemory struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockMemoryExpectation
expectationSeries []*ObjectDescriptorMockMemoryExpectation
}
type ObjectDescriptorMockMemoryExpectation struct {
result *ObjectDescriptorMockMemoryResult
}
type ObjectDescriptorMockMemoryResult struct {
r []byte
}
//Expect specifies that invocation of ObjectDescriptor.Memory is expected from 1 to Infinity times
func (m *mObjectDescriptorMockMemory) Expect() *mObjectDescriptorMockMemory {
m.mock.MemoryFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockMemoryExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.Memory
func (m *mObjectDescriptorMockMemory) Return(r []byte) *ObjectDescriptorMock {
m.mock.MemoryFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockMemoryExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockMemoryResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.Memory is expected once
func (m *mObjectDescriptorMockMemory) ExpectOnce() *ObjectDescriptorMockMemoryExpectation {
m.mock.MemoryFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockMemoryExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockMemoryExpectation) Return(r []byte) {
e.result = &ObjectDescriptorMockMemoryResult{r}
}
//Set uses given function f as a mock of ObjectDescriptor.Memory method
func (m *mObjectDescriptorMockMemory) Set(f func() (r []byte)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.MemoryFunc = f
return m.mock
}
//Memory implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) Memory() (r []byte) {
counter := atomic.AddUint64(&m.MemoryPreCounter, 1)
defer atomic.AddUint64(&m.MemoryCounter, 1)
if len(m.MemoryMock.expectationSeries) > 0 {
if counter > uint64(len(m.MemoryMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Memory.")
return
}
result := m.MemoryMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Memory")
return
}
r = result.r
return
}
if m.MemoryMock.mainExpectation != nil {
result := m.MemoryMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Memory")
}
r = result.r
return
}
if m.MemoryFunc == nil {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Memory.")
return
}
return m.MemoryFunc()
}
//MemoryMinimockCounter returns a count of ObjectDescriptorMock.MemoryFunc invocations
func (m *ObjectDescriptorMock) MemoryMinimockCounter() uint64 {
return atomic.LoadUint64(&m.MemoryCounter)
}
//MemoryMinimockPreCounter returns the value of ObjectDescriptorMock.Memory invocations
func (m *ObjectDescriptorMock) MemoryMinimockPreCounter() uint64 {
return atomic.LoadUint64(&m.MemoryPreCounter)
}
//MemoryFinished returns true if mock invocations count is ok
func (m *ObjectDescriptorMock) MemoryFinished() bool {
// if expectation series were set then invocations count should be equal to expectations count
if len(m.MemoryMock.expectationSeries) > 0 {
return atomic.LoadUint64(&m.MemoryCounter) == uint64(len(m.MemoryMock.expectationSeries))
}
// if main expectation was set then invocations count should be greater than zero
if m.MemoryMock.mainExpectation != nil {
return atomic.LoadUint64(&m.MemoryCounter) > 0
}
// if func was set then invocations count should be greater than zero
if m.MemoryFunc != nil {
return atomic.LoadUint64(&m.MemoryCounter) > 0
}
return true
}
type mObjectDescriptorMockParent struct {
mock *ObjectDescriptorMock
mainExpectation *ObjectDescriptorMockParentExpectation
expectationSeries []*ObjectDescriptorMockParentExpectation
}
type ObjectDescriptorMockParentExpectation struct {
result *ObjectDescriptorMockParentResult
}
type ObjectDescriptorMockParentResult struct {
r *core.RecordRef
}
//Expect specifies that invocation of ObjectDescriptor.Parent is expected from 1 to Infinity times
func (m *mObjectDescriptorMockParent) Expect() *mObjectDescriptorMockParent {
m.mock.ParentFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockParentExpectation{}
}
return m
}
//Return specifies results of invocation of ObjectDescriptor.Parent
func (m *mObjectDescriptorMockParent) Return(r *core.RecordRef) *ObjectDescriptorMock {
m.mock.ParentFunc = nil
m.expectationSeries = nil
if m.mainExpectation == nil {
m.mainExpectation = &ObjectDescriptorMockParentExpectation{}
}
m.mainExpectation.result = &ObjectDescriptorMockParentResult{r}
return m.mock
}
//ExpectOnce specifies that invocation of ObjectDescriptor.Parent is expected once
func (m *mObjectDescriptorMockParent) ExpectOnce() *ObjectDescriptorMockParentExpectation {
m.mock.ParentFunc = nil
m.mainExpectation = nil
expectation := &ObjectDescriptorMockParentExpectation{}
m.expectationSeries = append(m.expectationSeries, expectation)
return expectation
}
func (e *ObjectDescriptorMockParentExpectation) Return(r *core.RecordRef) {
e.result = &ObjectDescriptorMockParentResult{r}
}
//Set uses given function f as a mock of ObjectDescriptor.Parent method
func (m *mObjectDescriptorMockParent) Set(f func() (r *core.RecordRef)) *ObjectDescriptorMock {
m.mainExpectation = nil
m.expectationSeries = nil
m.mock.ParentFunc = f
return m.mock
}
//Parent implements github.com/insolar/insolar/core.ObjectDescriptor interface
func (m *ObjectDescriptorMock) Parent() (r *core.RecordRef) {
counter := atomic.AddUint64(&m.ParentPreCounter, 1)
defer atomic.AddUint64(&m.ParentCounter, 1)
if len(m.ParentMock.expectationSeries) > 0 {
if counter > uint64(len(m.ParentMock.expectationSeries)) {
m.t.Fatalf("Unexpected call to ObjectDescriptorMock.Parent.")
return
}
result := m.ParentMock.expectationSeries[counter-1].result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Parent")
return
}
r = result.r
return
}
if m.ParentMock.mainExpectation != nil {
result := m.ParentMock.mainExpectation.result
if result == nil {
m.t.Fatal("No results are set for the ObjectDescriptorMock.Parent")