-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathdiscovery_node_mock.go
670 lines (550 loc) · 23.2 KB
/
discovery_node_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
package testutils
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"crypto"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
mm_insolar "github.com/insolar/insolar/insolar"
)
// DiscoveryNodeMock implements insolar.DiscoveryNode
type DiscoveryNodeMock struct {
t minimock.Tester
funcGetHost func() (s1 string)
inspectFuncGetHost func()
afterGetHostCounter uint64
beforeGetHostCounter uint64
GetHostMock mDiscoveryNodeMockGetHost
funcGetNodeRef func() (rp1 *mm_insolar.Reference)
inspectFuncGetNodeRef func()
afterGetNodeRefCounter uint64
beforeGetNodeRefCounter uint64
GetNodeRefMock mDiscoveryNodeMockGetNodeRef
funcGetPublicKey func() (p1 crypto.PublicKey)
inspectFuncGetPublicKey func()
afterGetPublicKeyCounter uint64
beforeGetPublicKeyCounter uint64
GetPublicKeyMock mDiscoveryNodeMockGetPublicKey
funcGetRole func() (s1 mm_insolar.StaticRole)
inspectFuncGetRole func()
afterGetRoleCounter uint64
beforeGetRoleCounter uint64
GetRoleMock mDiscoveryNodeMockGetRole
}
// NewDiscoveryNodeMock returns a mock for insolar.DiscoveryNode
func NewDiscoveryNodeMock(t minimock.Tester) *DiscoveryNodeMock {
m := &DiscoveryNodeMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.GetHostMock = mDiscoveryNodeMockGetHost{mock: m}
m.GetNodeRefMock = mDiscoveryNodeMockGetNodeRef{mock: m}
m.GetPublicKeyMock = mDiscoveryNodeMockGetPublicKey{mock: m}
m.GetRoleMock = mDiscoveryNodeMockGetRole{mock: m}
return m
}
type mDiscoveryNodeMockGetHost struct {
mock *DiscoveryNodeMock
defaultExpectation *DiscoveryNodeMockGetHostExpectation
expectations []*DiscoveryNodeMockGetHostExpectation
}
// DiscoveryNodeMockGetHostExpectation specifies expectation struct of the DiscoveryNode.GetHost
type DiscoveryNodeMockGetHostExpectation struct {
mock *DiscoveryNodeMock
results *DiscoveryNodeMockGetHostResults
Counter uint64
}
// DiscoveryNodeMockGetHostResults contains results of the DiscoveryNode.GetHost
type DiscoveryNodeMockGetHostResults struct {
s1 string
}
// Expect sets up expected params for DiscoveryNode.GetHost
func (mmGetHost *mDiscoveryNodeMockGetHost) Expect() *mDiscoveryNodeMockGetHost {
if mmGetHost.mock.funcGetHost != nil {
mmGetHost.mock.t.Fatalf("DiscoveryNodeMock.GetHost mock is already set by Set")
}
if mmGetHost.defaultExpectation == nil {
mmGetHost.defaultExpectation = &DiscoveryNodeMockGetHostExpectation{}
}
return mmGetHost
}
// Inspect accepts an inspector function that has same arguments as the DiscoveryNode.GetHost
func (mmGetHost *mDiscoveryNodeMockGetHost) Inspect(f func()) *mDiscoveryNodeMockGetHost {
if mmGetHost.mock.inspectFuncGetHost != nil {
mmGetHost.mock.t.Fatalf("Inspect function is already set for DiscoveryNodeMock.GetHost")
}
mmGetHost.mock.inspectFuncGetHost = f
return mmGetHost
}
// Return sets up results that will be returned by DiscoveryNode.GetHost
func (mmGetHost *mDiscoveryNodeMockGetHost) Return(s1 string) *DiscoveryNodeMock {
if mmGetHost.mock.funcGetHost != nil {
mmGetHost.mock.t.Fatalf("DiscoveryNodeMock.GetHost mock is already set by Set")
}
if mmGetHost.defaultExpectation == nil {
mmGetHost.defaultExpectation = &DiscoveryNodeMockGetHostExpectation{mock: mmGetHost.mock}
}
mmGetHost.defaultExpectation.results = &DiscoveryNodeMockGetHostResults{s1}
return mmGetHost.mock
}
//Set uses given function f to mock the DiscoveryNode.GetHost method
func (mmGetHost *mDiscoveryNodeMockGetHost) Set(f func() (s1 string)) *DiscoveryNodeMock {
if mmGetHost.defaultExpectation != nil {
mmGetHost.mock.t.Fatalf("Default expectation is already set for the DiscoveryNode.GetHost method")
}
if len(mmGetHost.expectations) > 0 {
mmGetHost.mock.t.Fatalf("Some expectations are already set for the DiscoveryNode.GetHost method")
}
mmGetHost.mock.funcGetHost = f
return mmGetHost.mock
}
// GetHost implements insolar.DiscoveryNode
func (mmGetHost *DiscoveryNodeMock) GetHost() (s1 string) {
mm_atomic.AddUint64(&mmGetHost.beforeGetHostCounter, 1)
defer mm_atomic.AddUint64(&mmGetHost.afterGetHostCounter, 1)
if mmGetHost.inspectFuncGetHost != nil {
mmGetHost.inspectFuncGetHost()
}
if mmGetHost.GetHostMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmGetHost.GetHostMock.defaultExpectation.Counter, 1)
mm_results := mmGetHost.GetHostMock.defaultExpectation.results
if mm_results == nil {
mmGetHost.t.Fatal("No results are set for the DiscoveryNodeMock.GetHost")
}
return (*mm_results).s1
}
if mmGetHost.funcGetHost != nil {
return mmGetHost.funcGetHost()
}
mmGetHost.t.Fatalf("Unexpected call to DiscoveryNodeMock.GetHost.")
return
}
// GetHostAfterCounter returns a count of finished DiscoveryNodeMock.GetHost invocations
func (mmGetHost *DiscoveryNodeMock) GetHostAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetHost.afterGetHostCounter)
}
// GetHostBeforeCounter returns a count of DiscoveryNodeMock.GetHost invocations
func (mmGetHost *DiscoveryNodeMock) GetHostBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetHost.beforeGetHostCounter)
}
// MinimockGetHostDone returns true if the count of the GetHost invocations corresponds
// the number of defined expectations
func (m *DiscoveryNodeMock) MinimockGetHostDone() bool {
for _, e := range m.GetHostMock.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.GetHostMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetHostCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcGetHost != nil && mm_atomic.LoadUint64(&m.afterGetHostCounter) < 1 {
return false
}
return true
}
// MinimockGetHostInspect logs each unmet expectation
func (m *DiscoveryNodeMock) MinimockGetHostInspect() {
for _, e := range m.GetHostMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetHost")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetHostMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetHostCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetHost")
}
// if func was set then invocations count should be greater than zero
if m.funcGetHost != nil && mm_atomic.LoadUint64(&m.afterGetHostCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetHost")
}
}
type mDiscoveryNodeMockGetNodeRef struct {
mock *DiscoveryNodeMock
defaultExpectation *DiscoveryNodeMockGetNodeRefExpectation
expectations []*DiscoveryNodeMockGetNodeRefExpectation
}
// DiscoveryNodeMockGetNodeRefExpectation specifies expectation struct of the DiscoveryNode.GetNodeRef
type DiscoveryNodeMockGetNodeRefExpectation struct {
mock *DiscoveryNodeMock
results *DiscoveryNodeMockGetNodeRefResults
Counter uint64
}
// DiscoveryNodeMockGetNodeRefResults contains results of the DiscoveryNode.GetNodeRef
type DiscoveryNodeMockGetNodeRefResults struct {
rp1 *mm_insolar.Reference
}
// Expect sets up expected params for DiscoveryNode.GetNodeRef
func (mmGetNodeRef *mDiscoveryNodeMockGetNodeRef) Expect() *mDiscoveryNodeMockGetNodeRef {
if mmGetNodeRef.mock.funcGetNodeRef != nil {
mmGetNodeRef.mock.t.Fatalf("DiscoveryNodeMock.GetNodeRef mock is already set by Set")
}
if mmGetNodeRef.defaultExpectation == nil {
mmGetNodeRef.defaultExpectation = &DiscoveryNodeMockGetNodeRefExpectation{}
}
return mmGetNodeRef
}
// Inspect accepts an inspector function that has same arguments as the DiscoveryNode.GetNodeRef
func (mmGetNodeRef *mDiscoveryNodeMockGetNodeRef) Inspect(f func()) *mDiscoveryNodeMockGetNodeRef {
if mmGetNodeRef.mock.inspectFuncGetNodeRef != nil {
mmGetNodeRef.mock.t.Fatalf("Inspect function is already set for DiscoveryNodeMock.GetNodeRef")
}
mmGetNodeRef.mock.inspectFuncGetNodeRef = f
return mmGetNodeRef
}
// Return sets up results that will be returned by DiscoveryNode.GetNodeRef
func (mmGetNodeRef *mDiscoveryNodeMockGetNodeRef) Return(rp1 *mm_insolar.Reference) *DiscoveryNodeMock {
if mmGetNodeRef.mock.funcGetNodeRef != nil {
mmGetNodeRef.mock.t.Fatalf("DiscoveryNodeMock.GetNodeRef mock is already set by Set")
}
if mmGetNodeRef.defaultExpectation == nil {
mmGetNodeRef.defaultExpectation = &DiscoveryNodeMockGetNodeRefExpectation{mock: mmGetNodeRef.mock}
}
mmGetNodeRef.defaultExpectation.results = &DiscoveryNodeMockGetNodeRefResults{rp1}
return mmGetNodeRef.mock
}
//Set uses given function f to mock the DiscoveryNode.GetNodeRef method
func (mmGetNodeRef *mDiscoveryNodeMockGetNodeRef) Set(f func() (rp1 *mm_insolar.Reference)) *DiscoveryNodeMock {
if mmGetNodeRef.defaultExpectation != nil {
mmGetNodeRef.mock.t.Fatalf("Default expectation is already set for the DiscoveryNode.GetNodeRef method")
}
if len(mmGetNodeRef.expectations) > 0 {
mmGetNodeRef.mock.t.Fatalf("Some expectations are already set for the DiscoveryNode.GetNodeRef method")
}
mmGetNodeRef.mock.funcGetNodeRef = f
return mmGetNodeRef.mock
}
// GetNodeRef implements insolar.DiscoveryNode
func (mmGetNodeRef *DiscoveryNodeMock) GetNodeRef() (rp1 *mm_insolar.Reference) {
mm_atomic.AddUint64(&mmGetNodeRef.beforeGetNodeRefCounter, 1)
defer mm_atomic.AddUint64(&mmGetNodeRef.afterGetNodeRefCounter, 1)
if mmGetNodeRef.inspectFuncGetNodeRef != nil {
mmGetNodeRef.inspectFuncGetNodeRef()
}
if mmGetNodeRef.GetNodeRefMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmGetNodeRef.GetNodeRefMock.defaultExpectation.Counter, 1)
mm_results := mmGetNodeRef.GetNodeRefMock.defaultExpectation.results
if mm_results == nil {
mmGetNodeRef.t.Fatal("No results are set for the DiscoveryNodeMock.GetNodeRef")
}
return (*mm_results).rp1
}
if mmGetNodeRef.funcGetNodeRef != nil {
return mmGetNodeRef.funcGetNodeRef()
}
mmGetNodeRef.t.Fatalf("Unexpected call to DiscoveryNodeMock.GetNodeRef.")
return
}
// GetNodeRefAfterCounter returns a count of finished DiscoveryNodeMock.GetNodeRef invocations
func (mmGetNodeRef *DiscoveryNodeMock) GetNodeRefAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetNodeRef.afterGetNodeRefCounter)
}
// GetNodeRefBeforeCounter returns a count of DiscoveryNodeMock.GetNodeRef invocations
func (mmGetNodeRef *DiscoveryNodeMock) GetNodeRefBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetNodeRef.beforeGetNodeRefCounter)
}
// MinimockGetNodeRefDone returns true if the count of the GetNodeRef invocations corresponds
// the number of defined expectations
func (m *DiscoveryNodeMock) MinimockGetNodeRefDone() bool {
for _, e := range m.GetNodeRefMock.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.GetNodeRefMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetNodeRefCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcGetNodeRef != nil && mm_atomic.LoadUint64(&m.afterGetNodeRefCounter) < 1 {
return false
}
return true
}
// MinimockGetNodeRefInspect logs each unmet expectation
func (m *DiscoveryNodeMock) MinimockGetNodeRefInspect() {
for _, e := range m.GetNodeRefMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetNodeRef")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetNodeRefMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetNodeRefCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetNodeRef")
}
// if func was set then invocations count should be greater than zero
if m.funcGetNodeRef != nil && mm_atomic.LoadUint64(&m.afterGetNodeRefCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetNodeRef")
}
}
type mDiscoveryNodeMockGetPublicKey struct {
mock *DiscoveryNodeMock
defaultExpectation *DiscoveryNodeMockGetPublicKeyExpectation
expectations []*DiscoveryNodeMockGetPublicKeyExpectation
}
// DiscoveryNodeMockGetPublicKeyExpectation specifies expectation struct of the DiscoveryNode.GetPublicKey
type DiscoveryNodeMockGetPublicKeyExpectation struct {
mock *DiscoveryNodeMock
results *DiscoveryNodeMockGetPublicKeyResults
Counter uint64
}
// DiscoveryNodeMockGetPublicKeyResults contains results of the DiscoveryNode.GetPublicKey
type DiscoveryNodeMockGetPublicKeyResults struct {
p1 crypto.PublicKey
}
// Expect sets up expected params for DiscoveryNode.GetPublicKey
func (mmGetPublicKey *mDiscoveryNodeMockGetPublicKey) Expect() *mDiscoveryNodeMockGetPublicKey {
if mmGetPublicKey.mock.funcGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("DiscoveryNodeMock.GetPublicKey mock is already set by Set")
}
if mmGetPublicKey.defaultExpectation == nil {
mmGetPublicKey.defaultExpectation = &DiscoveryNodeMockGetPublicKeyExpectation{}
}
return mmGetPublicKey
}
// Inspect accepts an inspector function that has same arguments as the DiscoveryNode.GetPublicKey
func (mmGetPublicKey *mDiscoveryNodeMockGetPublicKey) Inspect(f func()) *mDiscoveryNodeMockGetPublicKey {
if mmGetPublicKey.mock.inspectFuncGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("Inspect function is already set for DiscoveryNodeMock.GetPublicKey")
}
mmGetPublicKey.mock.inspectFuncGetPublicKey = f
return mmGetPublicKey
}
// Return sets up results that will be returned by DiscoveryNode.GetPublicKey
func (mmGetPublicKey *mDiscoveryNodeMockGetPublicKey) Return(p1 crypto.PublicKey) *DiscoveryNodeMock {
if mmGetPublicKey.mock.funcGetPublicKey != nil {
mmGetPublicKey.mock.t.Fatalf("DiscoveryNodeMock.GetPublicKey mock is already set by Set")
}
if mmGetPublicKey.defaultExpectation == nil {
mmGetPublicKey.defaultExpectation = &DiscoveryNodeMockGetPublicKeyExpectation{mock: mmGetPublicKey.mock}
}
mmGetPublicKey.defaultExpectation.results = &DiscoveryNodeMockGetPublicKeyResults{p1}
return mmGetPublicKey.mock
}
//Set uses given function f to mock the DiscoveryNode.GetPublicKey method
func (mmGetPublicKey *mDiscoveryNodeMockGetPublicKey) Set(f func() (p1 crypto.PublicKey)) *DiscoveryNodeMock {
if mmGetPublicKey.defaultExpectation != nil {
mmGetPublicKey.mock.t.Fatalf("Default expectation is already set for the DiscoveryNode.GetPublicKey method")
}
if len(mmGetPublicKey.expectations) > 0 {
mmGetPublicKey.mock.t.Fatalf("Some expectations are already set for the DiscoveryNode.GetPublicKey method")
}
mmGetPublicKey.mock.funcGetPublicKey = f
return mmGetPublicKey.mock
}
// GetPublicKey implements insolar.DiscoveryNode
func (mmGetPublicKey *DiscoveryNodeMock) GetPublicKey() (p1 crypto.PublicKey) {
mm_atomic.AddUint64(&mmGetPublicKey.beforeGetPublicKeyCounter, 1)
defer mm_atomic.AddUint64(&mmGetPublicKey.afterGetPublicKeyCounter, 1)
if mmGetPublicKey.inspectFuncGetPublicKey != nil {
mmGetPublicKey.inspectFuncGetPublicKey()
}
if mmGetPublicKey.GetPublicKeyMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmGetPublicKey.GetPublicKeyMock.defaultExpectation.Counter, 1)
mm_results := mmGetPublicKey.GetPublicKeyMock.defaultExpectation.results
if mm_results == nil {
mmGetPublicKey.t.Fatal("No results are set for the DiscoveryNodeMock.GetPublicKey")
}
return (*mm_results).p1
}
if mmGetPublicKey.funcGetPublicKey != nil {
return mmGetPublicKey.funcGetPublicKey()
}
mmGetPublicKey.t.Fatalf("Unexpected call to DiscoveryNodeMock.GetPublicKey.")
return
}
// GetPublicKeyAfterCounter returns a count of finished DiscoveryNodeMock.GetPublicKey invocations
func (mmGetPublicKey *DiscoveryNodeMock) GetPublicKeyAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetPublicKey.afterGetPublicKeyCounter)
}
// GetPublicKeyBeforeCounter returns a count of DiscoveryNodeMock.GetPublicKey invocations
func (mmGetPublicKey *DiscoveryNodeMock) GetPublicKeyBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetPublicKey.beforeGetPublicKeyCounter)
}
// MinimockGetPublicKeyDone returns true if the count of the GetPublicKey invocations corresponds
// the number of defined expectations
func (m *DiscoveryNodeMock) MinimockGetPublicKeyDone() bool {
for _, e := range m.GetPublicKeyMock.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.GetPublicKeyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcGetPublicKey != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
return false
}
return true
}
// MinimockGetPublicKeyInspect logs each unmet expectation
func (m *DiscoveryNodeMock) MinimockGetPublicKeyInspect() {
for _, e := range m.GetPublicKeyMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetPublicKey")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetPublicKeyMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetPublicKey")
}
// if func was set then invocations count should be greater than zero
if m.funcGetPublicKey != nil && mm_atomic.LoadUint64(&m.afterGetPublicKeyCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetPublicKey")
}
}
type mDiscoveryNodeMockGetRole struct {
mock *DiscoveryNodeMock
defaultExpectation *DiscoveryNodeMockGetRoleExpectation
expectations []*DiscoveryNodeMockGetRoleExpectation
}
// DiscoveryNodeMockGetRoleExpectation specifies expectation struct of the DiscoveryNode.GetRole
type DiscoveryNodeMockGetRoleExpectation struct {
mock *DiscoveryNodeMock
results *DiscoveryNodeMockGetRoleResults
Counter uint64
}
// DiscoveryNodeMockGetRoleResults contains results of the DiscoveryNode.GetRole
type DiscoveryNodeMockGetRoleResults struct {
s1 mm_insolar.StaticRole
}
// Expect sets up expected params for DiscoveryNode.GetRole
func (mmGetRole *mDiscoveryNodeMockGetRole) Expect() *mDiscoveryNodeMockGetRole {
if mmGetRole.mock.funcGetRole != nil {
mmGetRole.mock.t.Fatalf("DiscoveryNodeMock.GetRole mock is already set by Set")
}
if mmGetRole.defaultExpectation == nil {
mmGetRole.defaultExpectation = &DiscoveryNodeMockGetRoleExpectation{}
}
return mmGetRole
}
// Inspect accepts an inspector function that has same arguments as the DiscoveryNode.GetRole
func (mmGetRole *mDiscoveryNodeMockGetRole) Inspect(f func()) *mDiscoveryNodeMockGetRole {
if mmGetRole.mock.inspectFuncGetRole != nil {
mmGetRole.mock.t.Fatalf("Inspect function is already set for DiscoveryNodeMock.GetRole")
}
mmGetRole.mock.inspectFuncGetRole = f
return mmGetRole
}
// Return sets up results that will be returned by DiscoveryNode.GetRole
func (mmGetRole *mDiscoveryNodeMockGetRole) Return(s1 mm_insolar.StaticRole) *DiscoveryNodeMock {
if mmGetRole.mock.funcGetRole != nil {
mmGetRole.mock.t.Fatalf("DiscoveryNodeMock.GetRole mock is already set by Set")
}
if mmGetRole.defaultExpectation == nil {
mmGetRole.defaultExpectation = &DiscoveryNodeMockGetRoleExpectation{mock: mmGetRole.mock}
}
mmGetRole.defaultExpectation.results = &DiscoveryNodeMockGetRoleResults{s1}
return mmGetRole.mock
}
//Set uses given function f to mock the DiscoveryNode.GetRole method
func (mmGetRole *mDiscoveryNodeMockGetRole) Set(f func() (s1 mm_insolar.StaticRole)) *DiscoveryNodeMock {
if mmGetRole.defaultExpectation != nil {
mmGetRole.mock.t.Fatalf("Default expectation is already set for the DiscoveryNode.GetRole method")
}
if len(mmGetRole.expectations) > 0 {
mmGetRole.mock.t.Fatalf("Some expectations are already set for the DiscoveryNode.GetRole method")
}
mmGetRole.mock.funcGetRole = f
return mmGetRole.mock
}
// GetRole implements insolar.DiscoveryNode
func (mmGetRole *DiscoveryNodeMock) GetRole() (s1 mm_insolar.StaticRole) {
mm_atomic.AddUint64(&mmGetRole.beforeGetRoleCounter, 1)
defer mm_atomic.AddUint64(&mmGetRole.afterGetRoleCounter, 1)
if mmGetRole.inspectFuncGetRole != nil {
mmGetRole.inspectFuncGetRole()
}
if mmGetRole.GetRoleMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmGetRole.GetRoleMock.defaultExpectation.Counter, 1)
mm_results := mmGetRole.GetRoleMock.defaultExpectation.results
if mm_results == nil {
mmGetRole.t.Fatal("No results are set for the DiscoveryNodeMock.GetRole")
}
return (*mm_results).s1
}
if mmGetRole.funcGetRole != nil {
return mmGetRole.funcGetRole()
}
mmGetRole.t.Fatalf("Unexpected call to DiscoveryNodeMock.GetRole.")
return
}
// GetRoleAfterCounter returns a count of finished DiscoveryNodeMock.GetRole invocations
func (mmGetRole *DiscoveryNodeMock) GetRoleAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetRole.afterGetRoleCounter)
}
// GetRoleBeforeCounter returns a count of DiscoveryNodeMock.GetRole invocations
func (mmGetRole *DiscoveryNodeMock) GetRoleBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmGetRole.beforeGetRoleCounter)
}
// MinimockGetRoleDone returns true if the count of the GetRole invocations corresponds
// the number of defined expectations
func (m *DiscoveryNodeMock) MinimockGetRoleDone() bool {
for _, e := range m.GetRoleMock.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.GetRoleMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcGetRole != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {
return false
}
return true
}
// MinimockGetRoleInspect logs each unmet expectation
func (m *DiscoveryNodeMock) MinimockGetRoleInspect() {
for _, e := range m.GetRoleMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetRole")
}
}
// if default expectation was set then invocations count should be greater than zero
if m.GetRoleMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetRole")
}
// if func was set then invocations count should be greater than zero
if m.funcGetRole != nil && mm_atomic.LoadUint64(&m.afterGetRoleCounter) < 1 {
m.t.Error("Expected call to DiscoveryNodeMock.GetRole")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *DiscoveryNodeMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockGetHostInspect()
m.MinimockGetNodeRefInspect()
m.MinimockGetPublicKeyInspect()
m.MinimockGetRoleInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *DiscoveryNodeMock) MinimockWait(timeout mm_time.Duration) {
timeoutCh := mm_time.After(timeout)
for {
if m.minimockDone() {
return
}
select {
case <-timeoutCh:
m.MinimockFinish()
return
case <-mm_time.After(10 * mm_time.Millisecond):
}
}
}
func (m *DiscoveryNodeMock) minimockDone() bool {
done := true
return done &&
m.MinimockGetHostDone() &&
m.MinimockGetNodeRefDone() &&
m.MinimockGetPublicKeyDone() &&
m.MinimockGetRoleDone()
}