-
Notifications
You must be signed in to change notification settings - Fork 46
/
outgoing_request_sender_mock.go
688 lines (560 loc) · 30.8 KB
/
outgoing_request_sender_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
package logicrunner
// 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"
"github.com/insolar/insolar/insolar/record"
)
// OutgoingRequestSenderMock implements OutgoingRequestSender
type OutgoingRequestSenderMock struct {
t minimock.Tester
funcSendAbandonedOutgoingRequest func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)
inspectFuncSendAbandonedOutgoingRequest func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)
afterSendAbandonedOutgoingRequestCounter uint64
beforeSendAbandonedOutgoingRequestCounter uint64
SendAbandonedOutgoingRequestMock mOutgoingRequestSenderMockSendAbandonedOutgoingRequest
funcSendOutgoingRequest func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) (rp1 *insolar.Reference, a1 insolar.Arguments, ip1 *record.IncomingRequest, err error)
inspectFuncSendOutgoingRequest func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)
afterSendOutgoingRequestCounter uint64
beforeSendOutgoingRequestCounter uint64
SendOutgoingRequestMock mOutgoingRequestSenderMockSendOutgoingRequest
funcStop func(ctx context.Context)
inspectFuncStop func(ctx context.Context)
afterStopCounter uint64
beforeStopCounter uint64
StopMock mOutgoingRequestSenderMockStop
}
// NewOutgoingRequestSenderMock returns a mock for OutgoingRequestSender
func NewOutgoingRequestSenderMock(t minimock.Tester) *OutgoingRequestSenderMock {
m := &OutgoingRequestSenderMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.SendAbandonedOutgoingRequestMock = mOutgoingRequestSenderMockSendAbandonedOutgoingRequest{mock: m}
m.SendAbandonedOutgoingRequestMock.callArgs = []*OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams{}
m.SendOutgoingRequestMock = mOutgoingRequestSenderMockSendOutgoingRequest{mock: m}
m.SendOutgoingRequestMock.callArgs = []*OutgoingRequestSenderMockSendOutgoingRequestParams{}
m.StopMock = mOutgoingRequestSenderMockStop{mock: m}
m.StopMock.callArgs = []*OutgoingRequestSenderMockStopParams{}
return m
}
type mOutgoingRequestSenderMockSendAbandonedOutgoingRequest struct {
mock *OutgoingRequestSenderMock
defaultExpectation *OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation
expectations []*OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation
callArgs []*OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams
mutex sync.RWMutex
}
// OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation specifies expectation struct of the OutgoingRequestSender.SendAbandonedOutgoingRequest
type OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation struct {
mock *OutgoingRequestSenderMock
params *OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams
Counter uint64
}
// OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams contains parameters of the OutgoingRequestSender.SendAbandonedOutgoingRequest
type OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams struct {
ctx context.Context
reqRef insolar.Reference
req *record.OutgoingRequest
}
// Expect sets up expected params for OutgoingRequestSender.SendAbandonedOutgoingRequest
func (mmSendAbandonedOutgoingRequest *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest) Expect(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest {
if mmSendAbandonedOutgoingRequest.mock.funcSendAbandonedOutgoingRequest != nil {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("OutgoingRequestSenderMock.SendAbandonedOutgoingRequest mock is already set by Set")
}
if mmSendAbandonedOutgoingRequest.defaultExpectation == nil {
mmSendAbandonedOutgoingRequest.defaultExpectation = &OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation{}
}
mmSendAbandonedOutgoingRequest.defaultExpectation.params = &OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams{ctx, reqRef, req}
for _, e := range mmSendAbandonedOutgoingRequest.expectations {
if minimock.Equal(e.params, mmSendAbandonedOutgoingRequest.defaultExpectation.params) {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSendAbandonedOutgoingRequest.defaultExpectation.params)
}
}
return mmSendAbandonedOutgoingRequest
}
// Inspect accepts an inspector function that has same arguments as the OutgoingRequestSender.SendAbandonedOutgoingRequest
func (mmSendAbandonedOutgoingRequest *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest) Inspect(f func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)) *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest {
if mmSendAbandonedOutgoingRequest.mock.inspectFuncSendAbandonedOutgoingRequest != nil {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("Inspect function is already set for OutgoingRequestSenderMock.SendAbandonedOutgoingRequest")
}
mmSendAbandonedOutgoingRequest.mock.inspectFuncSendAbandonedOutgoingRequest = f
return mmSendAbandonedOutgoingRequest
}
// Return sets up results that will be returned by OutgoingRequestSender.SendAbandonedOutgoingRequest
func (mmSendAbandonedOutgoingRequest *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest) Return() *OutgoingRequestSenderMock {
if mmSendAbandonedOutgoingRequest.mock.funcSendAbandonedOutgoingRequest != nil {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("OutgoingRequestSenderMock.SendAbandonedOutgoingRequest mock is already set by Set")
}
if mmSendAbandonedOutgoingRequest.defaultExpectation == nil {
mmSendAbandonedOutgoingRequest.defaultExpectation = &OutgoingRequestSenderMockSendAbandonedOutgoingRequestExpectation{mock: mmSendAbandonedOutgoingRequest.mock}
}
return mmSendAbandonedOutgoingRequest.mock
}
//Set uses given function f to mock the OutgoingRequestSender.SendAbandonedOutgoingRequest method
func (mmSendAbandonedOutgoingRequest *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest) Set(f func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)) *OutgoingRequestSenderMock {
if mmSendAbandonedOutgoingRequest.defaultExpectation != nil {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("Default expectation is already set for the OutgoingRequestSender.SendAbandonedOutgoingRequest method")
}
if len(mmSendAbandonedOutgoingRequest.expectations) > 0 {
mmSendAbandonedOutgoingRequest.mock.t.Fatalf("Some expectations are already set for the OutgoingRequestSender.SendAbandonedOutgoingRequest method")
}
mmSendAbandonedOutgoingRequest.mock.funcSendAbandonedOutgoingRequest = f
return mmSendAbandonedOutgoingRequest.mock
}
// SendAbandonedOutgoingRequest implements OutgoingRequestSender
func (mmSendAbandonedOutgoingRequest *OutgoingRequestSenderMock) SendAbandonedOutgoingRequest(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) {
mm_atomic.AddUint64(&mmSendAbandonedOutgoingRequest.beforeSendAbandonedOutgoingRequestCounter, 1)
defer mm_atomic.AddUint64(&mmSendAbandonedOutgoingRequest.afterSendAbandonedOutgoingRequestCounter, 1)
if mmSendAbandonedOutgoingRequest.inspectFuncSendAbandonedOutgoingRequest != nil {
mmSendAbandonedOutgoingRequest.inspectFuncSendAbandonedOutgoingRequest(ctx, reqRef, req)
}
params := &OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams{ctx, reqRef, req}
// Record call args
mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.mutex.Lock()
mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.callArgs = append(mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.callArgs, params)
mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.mutex.Unlock()
for _, e := range mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return
}
}
if mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.defaultExpectation.Counter, 1)
want := mmSendAbandonedOutgoingRequest.SendAbandonedOutgoingRequestMock.defaultExpectation.params
got := OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams{ctx, reqRef, req}
if want != nil && !minimock.Equal(*want, got) {
mmSendAbandonedOutgoingRequest.t.Errorf("OutgoingRequestSenderMock.SendAbandonedOutgoingRequest got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
return
}
if mmSendAbandonedOutgoingRequest.funcSendAbandonedOutgoingRequest != nil {
mmSendAbandonedOutgoingRequest.funcSendAbandonedOutgoingRequest(ctx, reqRef, req)
return
}
mmSendAbandonedOutgoingRequest.t.Fatalf("Unexpected call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest. %v %v %v", ctx, reqRef, req)
}
// SendAbandonedOutgoingRequestAfterCounter returns a count of finished OutgoingRequestSenderMock.SendAbandonedOutgoingRequest invocations
func (mmSendAbandonedOutgoingRequest *OutgoingRequestSenderMock) SendAbandonedOutgoingRequestAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmSendAbandonedOutgoingRequest.afterSendAbandonedOutgoingRequestCounter)
}
// SendAbandonedOutgoingRequestBeforeCounter returns a count of OutgoingRequestSenderMock.SendAbandonedOutgoingRequest invocations
func (mmSendAbandonedOutgoingRequest *OutgoingRequestSenderMock) SendAbandonedOutgoingRequestBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmSendAbandonedOutgoingRequest.beforeSendAbandonedOutgoingRequestCounter)
}
// Calls returns a list of arguments used in each call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmSendAbandonedOutgoingRequest *mOutgoingRequestSenderMockSendAbandonedOutgoingRequest) Calls() []*OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams {
mmSendAbandonedOutgoingRequest.mutex.RLock()
argCopy := make([]*OutgoingRequestSenderMockSendAbandonedOutgoingRequestParams, len(mmSendAbandonedOutgoingRequest.callArgs))
copy(argCopy, mmSendAbandonedOutgoingRequest.callArgs)
mmSendAbandonedOutgoingRequest.mutex.RUnlock()
return argCopy
}
// MinimockSendAbandonedOutgoingRequestDone returns true if the count of the SendAbandonedOutgoingRequest invocations corresponds
// the number of defined expectations
func (m *OutgoingRequestSenderMock) MinimockSendAbandonedOutgoingRequestDone() bool {
for _, e := range m.SendAbandonedOutgoingRequestMock.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.SendAbandonedOutgoingRequestMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendAbandonedOutgoingRequestCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcSendAbandonedOutgoingRequest != nil && mm_atomic.LoadUint64(&m.afterSendAbandonedOutgoingRequestCounter) < 1 {
return false
}
return true
}
// MinimockSendAbandonedOutgoingRequestInspect logs each unmet expectation
func (m *OutgoingRequestSenderMock) MinimockSendAbandonedOutgoingRequestInspect() {
for _, e := range m.SendAbandonedOutgoingRequestMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.SendAbandonedOutgoingRequestMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendAbandonedOutgoingRequestCounter) < 1 {
if m.SendAbandonedOutgoingRequestMock.defaultExpectation.params == nil {
m.t.Error("Expected call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest")
} else {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest with params: %#v", *m.SendAbandonedOutgoingRequestMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcSendAbandonedOutgoingRequest != nil && mm_atomic.LoadUint64(&m.afterSendAbandonedOutgoingRequestCounter) < 1 {
m.t.Error("Expected call to OutgoingRequestSenderMock.SendAbandonedOutgoingRequest")
}
}
type mOutgoingRequestSenderMockSendOutgoingRequest struct {
mock *OutgoingRequestSenderMock
defaultExpectation *OutgoingRequestSenderMockSendOutgoingRequestExpectation
expectations []*OutgoingRequestSenderMockSendOutgoingRequestExpectation
callArgs []*OutgoingRequestSenderMockSendOutgoingRequestParams
mutex sync.RWMutex
}
// OutgoingRequestSenderMockSendOutgoingRequestExpectation specifies expectation struct of the OutgoingRequestSender.SendOutgoingRequest
type OutgoingRequestSenderMockSendOutgoingRequestExpectation struct {
mock *OutgoingRequestSenderMock
params *OutgoingRequestSenderMockSendOutgoingRequestParams
results *OutgoingRequestSenderMockSendOutgoingRequestResults
Counter uint64
}
// OutgoingRequestSenderMockSendOutgoingRequestParams contains parameters of the OutgoingRequestSender.SendOutgoingRequest
type OutgoingRequestSenderMockSendOutgoingRequestParams struct {
ctx context.Context
reqRef insolar.Reference
req *record.OutgoingRequest
}
// OutgoingRequestSenderMockSendOutgoingRequestResults contains results of the OutgoingRequestSender.SendOutgoingRequest
type OutgoingRequestSenderMockSendOutgoingRequestResults struct {
rp1 *insolar.Reference
a1 insolar.Arguments
ip1 *record.IncomingRequest
err error
}
// Expect sets up expected params for OutgoingRequestSender.SendOutgoingRequest
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) Expect(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) *mOutgoingRequestSenderMockSendOutgoingRequest {
if mmSendOutgoingRequest.mock.funcSendOutgoingRequest != nil {
mmSendOutgoingRequest.mock.t.Fatalf("OutgoingRequestSenderMock.SendOutgoingRequest mock is already set by Set")
}
if mmSendOutgoingRequest.defaultExpectation == nil {
mmSendOutgoingRequest.defaultExpectation = &OutgoingRequestSenderMockSendOutgoingRequestExpectation{}
}
mmSendOutgoingRequest.defaultExpectation.params = &OutgoingRequestSenderMockSendOutgoingRequestParams{ctx, reqRef, req}
for _, e := range mmSendOutgoingRequest.expectations {
if minimock.Equal(e.params, mmSendOutgoingRequest.defaultExpectation.params) {
mmSendOutgoingRequest.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmSendOutgoingRequest.defaultExpectation.params)
}
}
return mmSendOutgoingRequest
}
// Inspect accepts an inspector function that has same arguments as the OutgoingRequestSender.SendOutgoingRequest
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) Inspect(f func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest)) *mOutgoingRequestSenderMockSendOutgoingRequest {
if mmSendOutgoingRequest.mock.inspectFuncSendOutgoingRequest != nil {
mmSendOutgoingRequest.mock.t.Fatalf("Inspect function is already set for OutgoingRequestSenderMock.SendOutgoingRequest")
}
mmSendOutgoingRequest.mock.inspectFuncSendOutgoingRequest = f
return mmSendOutgoingRequest
}
// Return sets up results that will be returned by OutgoingRequestSender.SendOutgoingRequest
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) Return(rp1 *insolar.Reference, a1 insolar.Arguments, ip1 *record.IncomingRequest, err error) *OutgoingRequestSenderMock {
if mmSendOutgoingRequest.mock.funcSendOutgoingRequest != nil {
mmSendOutgoingRequest.mock.t.Fatalf("OutgoingRequestSenderMock.SendOutgoingRequest mock is already set by Set")
}
if mmSendOutgoingRequest.defaultExpectation == nil {
mmSendOutgoingRequest.defaultExpectation = &OutgoingRequestSenderMockSendOutgoingRequestExpectation{mock: mmSendOutgoingRequest.mock}
}
mmSendOutgoingRequest.defaultExpectation.results = &OutgoingRequestSenderMockSendOutgoingRequestResults{rp1, a1, ip1, err}
return mmSendOutgoingRequest.mock
}
//Set uses given function f to mock the OutgoingRequestSender.SendOutgoingRequest method
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) Set(f func(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) (rp1 *insolar.Reference, a1 insolar.Arguments, ip1 *record.IncomingRequest, err error)) *OutgoingRequestSenderMock {
if mmSendOutgoingRequest.defaultExpectation != nil {
mmSendOutgoingRequest.mock.t.Fatalf("Default expectation is already set for the OutgoingRequestSender.SendOutgoingRequest method")
}
if len(mmSendOutgoingRequest.expectations) > 0 {
mmSendOutgoingRequest.mock.t.Fatalf("Some expectations are already set for the OutgoingRequestSender.SendOutgoingRequest method")
}
mmSendOutgoingRequest.mock.funcSendOutgoingRequest = f
return mmSendOutgoingRequest.mock
}
// When sets expectation for the OutgoingRequestSender.SendOutgoingRequest which will trigger the result defined by the following
// Then helper
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) When(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) *OutgoingRequestSenderMockSendOutgoingRequestExpectation {
if mmSendOutgoingRequest.mock.funcSendOutgoingRequest != nil {
mmSendOutgoingRequest.mock.t.Fatalf("OutgoingRequestSenderMock.SendOutgoingRequest mock is already set by Set")
}
expectation := &OutgoingRequestSenderMockSendOutgoingRequestExpectation{
mock: mmSendOutgoingRequest.mock,
params: &OutgoingRequestSenderMockSendOutgoingRequestParams{ctx, reqRef, req},
}
mmSendOutgoingRequest.expectations = append(mmSendOutgoingRequest.expectations, expectation)
return expectation
}
// Then sets up OutgoingRequestSender.SendOutgoingRequest return parameters for the expectation previously defined by the When method
func (e *OutgoingRequestSenderMockSendOutgoingRequestExpectation) Then(rp1 *insolar.Reference, a1 insolar.Arguments, ip1 *record.IncomingRequest, err error) *OutgoingRequestSenderMock {
e.results = &OutgoingRequestSenderMockSendOutgoingRequestResults{rp1, a1, ip1, err}
return e.mock
}
// SendOutgoingRequest implements OutgoingRequestSender
func (mmSendOutgoingRequest *OutgoingRequestSenderMock) SendOutgoingRequest(ctx context.Context, reqRef insolar.Reference, req *record.OutgoingRequest) (rp1 *insolar.Reference, a1 insolar.Arguments, ip1 *record.IncomingRequest, err error) {
mm_atomic.AddUint64(&mmSendOutgoingRequest.beforeSendOutgoingRequestCounter, 1)
defer mm_atomic.AddUint64(&mmSendOutgoingRequest.afterSendOutgoingRequestCounter, 1)
if mmSendOutgoingRequest.inspectFuncSendOutgoingRequest != nil {
mmSendOutgoingRequest.inspectFuncSendOutgoingRequest(ctx, reqRef, req)
}
params := &OutgoingRequestSenderMockSendOutgoingRequestParams{ctx, reqRef, req}
// Record call args
mmSendOutgoingRequest.SendOutgoingRequestMock.mutex.Lock()
mmSendOutgoingRequest.SendOutgoingRequestMock.callArgs = append(mmSendOutgoingRequest.SendOutgoingRequestMock.callArgs, params)
mmSendOutgoingRequest.SendOutgoingRequestMock.mutex.Unlock()
for _, e := range mmSendOutgoingRequest.SendOutgoingRequestMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.rp1, e.results.a1, e.results.ip1, e.results.err
}
}
if mmSendOutgoingRequest.SendOutgoingRequestMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmSendOutgoingRequest.SendOutgoingRequestMock.defaultExpectation.Counter, 1)
want := mmSendOutgoingRequest.SendOutgoingRequestMock.defaultExpectation.params
got := OutgoingRequestSenderMockSendOutgoingRequestParams{ctx, reqRef, req}
if want != nil && !minimock.Equal(*want, got) {
mmSendOutgoingRequest.t.Errorf("OutgoingRequestSenderMock.SendOutgoingRequest got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmSendOutgoingRequest.SendOutgoingRequestMock.defaultExpectation.results
if results == nil {
mmSendOutgoingRequest.t.Fatal("No results are set for the OutgoingRequestSenderMock.SendOutgoingRequest")
}
return (*results).rp1, (*results).a1, (*results).ip1, (*results).err
}
if mmSendOutgoingRequest.funcSendOutgoingRequest != nil {
return mmSendOutgoingRequest.funcSendOutgoingRequest(ctx, reqRef, req)
}
mmSendOutgoingRequest.t.Fatalf("Unexpected call to OutgoingRequestSenderMock.SendOutgoingRequest. %v %v %v", ctx, reqRef, req)
return
}
// SendOutgoingRequestAfterCounter returns a count of finished OutgoingRequestSenderMock.SendOutgoingRequest invocations
func (mmSendOutgoingRequest *OutgoingRequestSenderMock) SendOutgoingRequestAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmSendOutgoingRequest.afterSendOutgoingRequestCounter)
}
// SendOutgoingRequestBeforeCounter returns a count of OutgoingRequestSenderMock.SendOutgoingRequest invocations
func (mmSendOutgoingRequest *OutgoingRequestSenderMock) SendOutgoingRequestBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmSendOutgoingRequest.beforeSendOutgoingRequestCounter)
}
// Calls returns a list of arguments used in each call to OutgoingRequestSenderMock.SendOutgoingRequest.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmSendOutgoingRequest *mOutgoingRequestSenderMockSendOutgoingRequest) Calls() []*OutgoingRequestSenderMockSendOutgoingRequestParams {
mmSendOutgoingRequest.mutex.RLock()
argCopy := make([]*OutgoingRequestSenderMockSendOutgoingRequestParams, len(mmSendOutgoingRequest.callArgs))
copy(argCopy, mmSendOutgoingRequest.callArgs)
mmSendOutgoingRequest.mutex.RUnlock()
return argCopy
}
// MinimockSendOutgoingRequestDone returns true if the count of the SendOutgoingRequest invocations corresponds
// the number of defined expectations
func (m *OutgoingRequestSenderMock) MinimockSendOutgoingRequestDone() bool {
for _, e := range m.SendOutgoingRequestMock.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.SendOutgoingRequestMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendOutgoingRequestCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcSendOutgoingRequest != nil && mm_atomic.LoadUint64(&m.afterSendOutgoingRequestCounter) < 1 {
return false
}
return true
}
// MinimockSendOutgoingRequestInspect logs each unmet expectation
func (m *OutgoingRequestSenderMock) MinimockSendOutgoingRequestInspect() {
for _, e := range m.SendOutgoingRequestMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.SendOutgoingRequest with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.SendOutgoingRequestMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterSendOutgoingRequestCounter) < 1 {
if m.SendOutgoingRequestMock.defaultExpectation.params == nil {
m.t.Error("Expected call to OutgoingRequestSenderMock.SendOutgoingRequest")
} else {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.SendOutgoingRequest with params: %#v", *m.SendOutgoingRequestMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcSendOutgoingRequest != nil && mm_atomic.LoadUint64(&m.afterSendOutgoingRequestCounter) < 1 {
m.t.Error("Expected call to OutgoingRequestSenderMock.SendOutgoingRequest")
}
}
type mOutgoingRequestSenderMockStop struct {
mock *OutgoingRequestSenderMock
defaultExpectation *OutgoingRequestSenderMockStopExpectation
expectations []*OutgoingRequestSenderMockStopExpectation
callArgs []*OutgoingRequestSenderMockStopParams
mutex sync.RWMutex
}
// OutgoingRequestSenderMockStopExpectation specifies expectation struct of the OutgoingRequestSender.Stop
type OutgoingRequestSenderMockStopExpectation struct {
mock *OutgoingRequestSenderMock
params *OutgoingRequestSenderMockStopParams
Counter uint64
}
// OutgoingRequestSenderMockStopParams contains parameters of the OutgoingRequestSender.Stop
type OutgoingRequestSenderMockStopParams struct {
ctx context.Context
}
// Expect sets up expected params for OutgoingRequestSender.Stop
func (mmStop *mOutgoingRequestSenderMockStop) Expect(ctx context.Context) *mOutgoingRequestSenderMockStop {
if mmStop.mock.funcStop != nil {
mmStop.mock.t.Fatalf("OutgoingRequestSenderMock.Stop mock is already set by Set")
}
if mmStop.defaultExpectation == nil {
mmStop.defaultExpectation = &OutgoingRequestSenderMockStopExpectation{}
}
mmStop.defaultExpectation.params = &OutgoingRequestSenderMockStopParams{ctx}
for _, e := range mmStop.expectations {
if minimock.Equal(e.params, mmStop.defaultExpectation.params) {
mmStop.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmStop.defaultExpectation.params)
}
}
return mmStop
}
// Inspect accepts an inspector function that has same arguments as the OutgoingRequestSender.Stop
func (mmStop *mOutgoingRequestSenderMockStop) Inspect(f func(ctx context.Context)) *mOutgoingRequestSenderMockStop {
if mmStop.mock.inspectFuncStop != nil {
mmStop.mock.t.Fatalf("Inspect function is already set for OutgoingRequestSenderMock.Stop")
}
mmStop.mock.inspectFuncStop = f
return mmStop
}
// Return sets up results that will be returned by OutgoingRequestSender.Stop
func (mmStop *mOutgoingRequestSenderMockStop) Return() *OutgoingRequestSenderMock {
if mmStop.mock.funcStop != nil {
mmStop.mock.t.Fatalf("OutgoingRequestSenderMock.Stop mock is already set by Set")
}
if mmStop.defaultExpectation == nil {
mmStop.defaultExpectation = &OutgoingRequestSenderMockStopExpectation{mock: mmStop.mock}
}
return mmStop.mock
}
//Set uses given function f to mock the OutgoingRequestSender.Stop method
func (mmStop *mOutgoingRequestSenderMockStop) Set(f func(ctx context.Context)) *OutgoingRequestSenderMock {
if mmStop.defaultExpectation != nil {
mmStop.mock.t.Fatalf("Default expectation is already set for the OutgoingRequestSender.Stop method")
}
if len(mmStop.expectations) > 0 {
mmStop.mock.t.Fatalf("Some expectations are already set for the OutgoingRequestSender.Stop method")
}
mmStop.mock.funcStop = f
return mmStop.mock
}
// Stop implements OutgoingRequestSender
func (mmStop *OutgoingRequestSenderMock) Stop(ctx context.Context) {
mm_atomic.AddUint64(&mmStop.beforeStopCounter, 1)
defer mm_atomic.AddUint64(&mmStop.afterStopCounter, 1)
if mmStop.inspectFuncStop != nil {
mmStop.inspectFuncStop(ctx)
}
params := &OutgoingRequestSenderMockStopParams{ctx}
// Record call args
mmStop.StopMock.mutex.Lock()
mmStop.StopMock.callArgs = append(mmStop.StopMock.callArgs, params)
mmStop.StopMock.mutex.Unlock()
for _, e := range mmStop.StopMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return
}
}
if mmStop.StopMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmStop.StopMock.defaultExpectation.Counter, 1)
want := mmStop.StopMock.defaultExpectation.params
got := OutgoingRequestSenderMockStopParams{ctx}
if want != nil && !minimock.Equal(*want, got) {
mmStop.t.Errorf("OutgoingRequestSenderMock.Stop got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
return
}
if mmStop.funcStop != nil {
mmStop.funcStop(ctx)
return
}
mmStop.t.Fatalf("Unexpected call to OutgoingRequestSenderMock.Stop. %v", ctx)
}
// StopAfterCounter returns a count of finished OutgoingRequestSenderMock.Stop invocations
func (mmStop *OutgoingRequestSenderMock) StopAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmStop.afterStopCounter)
}
// StopBeforeCounter returns a count of OutgoingRequestSenderMock.Stop invocations
func (mmStop *OutgoingRequestSenderMock) StopBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmStop.beforeStopCounter)
}
// Calls returns a list of arguments used in each call to OutgoingRequestSenderMock.Stop.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmStop *mOutgoingRequestSenderMockStop) Calls() []*OutgoingRequestSenderMockStopParams {
mmStop.mutex.RLock()
argCopy := make([]*OutgoingRequestSenderMockStopParams, len(mmStop.callArgs))
copy(argCopy, mmStop.callArgs)
mmStop.mutex.RUnlock()
return argCopy
}
// MinimockStopDone returns true if the count of the Stop invocations corresponds
// the number of defined expectations
func (m *OutgoingRequestSenderMock) MinimockStopDone() bool {
for _, e := range m.StopMock.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.StopMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterStopCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcStop != nil && mm_atomic.LoadUint64(&m.afterStopCounter) < 1 {
return false
}
return true
}
// MinimockStopInspect logs each unmet expectation
func (m *OutgoingRequestSenderMock) MinimockStopInspect() {
for _, e := range m.StopMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.Stop with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.StopMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterStopCounter) < 1 {
if m.StopMock.defaultExpectation.params == nil {
m.t.Error("Expected call to OutgoingRequestSenderMock.Stop")
} else {
m.t.Errorf("Expected call to OutgoingRequestSenderMock.Stop with params: %#v", *m.StopMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcStop != nil && mm_atomic.LoadUint64(&m.afterStopCounter) < 1 {
m.t.Error("Expected call to OutgoingRequestSenderMock.Stop")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *OutgoingRequestSenderMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockSendAbandonedOutgoingRequestInspect()
m.MinimockSendOutgoingRequestInspect()
m.MinimockStopInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *OutgoingRequestSenderMock) 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 *OutgoingRequestSenderMock) minimockDone() bool {
done := true
return done &&
m.MinimockSendAbandonedOutgoingRequestDone() &&
m.MinimockSendOutgoingRequestDone() &&
m.MinimockStopDone()
}