-
Notifications
You must be signed in to change notification settings - Fork 4
/
payload_receptacle_mock.go
737 lines (609 loc) · 29.3 KB
/
payload_receptacle_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
package bundle
// Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT.
import (
"io"
"sync"
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
"github.com/insolar/assured-ledger/ledger-core/vanilla/longbits"
)
// PayloadReceptacleMock implements PayloadReceptacle
type PayloadReceptacleMock struct {
t minimock.Tester
funcApplyFixedReader func(f1 longbits.FixedReader) (err error)
inspectFuncApplyFixedReader func(f1 longbits.FixedReader)
afterApplyFixedReaderCounter uint64
beforeApplyFixedReaderCounter uint64
ApplyFixedReaderMock mPayloadReceptacleMockApplyFixedReader
funcApplyMarshalTo func(m1 MarshalerTo) (err error)
inspectFuncApplyMarshalTo func(m1 MarshalerTo)
afterApplyMarshalToCounter uint64
beforeApplyMarshalToCounter uint64
ApplyMarshalToMock mPayloadReceptacleMockApplyMarshalTo
funcWriteTo func(w io.Writer) (n int64, err error)
inspectFuncWriteTo func(w io.Writer)
afterWriteToCounter uint64
beforeWriteToCounter uint64
WriteToMock mPayloadReceptacleMockWriteTo
}
// NewPayloadReceptacleMock returns a mock for PayloadReceptacle
func NewPayloadReceptacleMock(t minimock.Tester) *PayloadReceptacleMock {
m := &PayloadReceptacleMock{t: t}
if controller, ok := t.(minimock.MockController); ok {
controller.RegisterMocker(m)
}
m.ApplyFixedReaderMock = mPayloadReceptacleMockApplyFixedReader{mock: m}
m.ApplyFixedReaderMock.callArgs = []*PayloadReceptacleMockApplyFixedReaderParams{}
m.ApplyMarshalToMock = mPayloadReceptacleMockApplyMarshalTo{mock: m}
m.ApplyMarshalToMock.callArgs = []*PayloadReceptacleMockApplyMarshalToParams{}
m.WriteToMock = mPayloadReceptacleMockWriteTo{mock: m}
m.WriteToMock.callArgs = []*PayloadReceptacleMockWriteToParams{}
return m
}
type mPayloadReceptacleMockApplyFixedReader struct {
mock *PayloadReceptacleMock
defaultExpectation *PayloadReceptacleMockApplyFixedReaderExpectation
expectations []*PayloadReceptacleMockApplyFixedReaderExpectation
callArgs []*PayloadReceptacleMockApplyFixedReaderParams
mutex sync.RWMutex
}
// PayloadReceptacleMockApplyFixedReaderExpectation specifies expectation struct of the PayloadReceptacle.ApplyFixedReader
type PayloadReceptacleMockApplyFixedReaderExpectation struct {
mock *PayloadReceptacleMock
params *PayloadReceptacleMockApplyFixedReaderParams
results *PayloadReceptacleMockApplyFixedReaderResults
Counter uint64
}
// PayloadReceptacleMockApplyFixedReaderParams contains parameters of the PayloadReceptacle.ApplyFixedReader
type PayloadReceptacleMockApplyFixedReaderParams struct {
f1 longbits.FixedReader
}
// PayloadReceptacleMockApplyFixedReaderResults contains results of the PayloadReceptacle.ApplyFixedReader
type PayloadReceptacleMockApplyFixedReaderResults struct {
err error
}
// Expect sets up expected params for PayloadReceptacle.ApplyFixedReader
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) Expect(f1 longbits.FixedReader) *mPayloadReceptacleMockApplyFixedReader {
if mmApplyFixedReader.mock.funcApplyFixedReader != nil {
mmApplyFixedReader.mock.t.Fatalf("PayloadReceptacleMock.ApplyFixedReader mock is already set by Set")
}
if mmApplyFixedReader.defaultExpectation == nil {
mmApplyFixedReader.defaultExpectation = &PayloadReceptacleMockApplyFixedReaderExpectation{}
}
mmApplyFixedReader.defaultExpectation.params = &PayloadReceptacleMockApplyFixedReaderParams{f1}
for _, e := range mmApplyFixedReader.expectations {
if minimock.Equal(e.params, mmApplyFixedReader.defaultExpectation.params) {
mmApplyFixedReader.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmApplyFixedReader.defaultExpectation.params)
}
}
return mmApplyFixedReader
}
// Inspect accepts an inspector function that has same arguments as the PayloadReceptacle.ApplyFixedReader
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) Inspect(f func(f1 longbits.FixedReader)) *mPayloadReceptacleMockApplyFixedReader {
if mmApplyFixedReader.mock.inspectFuncApplyFixedReader != nil {
mmApplyFixedReader.mock.t.Fatalf("Inspect function is already set for PayloadReceptacleMock.ApplyFixedReader")
}
mmApplyFixedReader.mock.inspectFuncApplyFixedReader = f
return mmApplyFixedReader
}
// Return sets up results that will be returned by PayloadReceptacle.ApplyFixedReader
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) Return(err error) *PayloadReceptacleMock {
if mmApplyFixedReader.mock.funcApplyFixedReader != nil {
mmApplyFixedReader.mock.t.Fatalf("PayloadReceptacleMock.ApplyFixedReader mock is already set by Set")
}
if mmApplyFixedReader.defaultExpectation == nil {
mmApplyFixedReader.defaultExpectation = &PayloadReceptacleMockApplyFixedReaderExpectation{mock: mmApplyFixedReader.mock}
}
mmApplyFixedReader.defaultExpectation.results = &PayloadReceptacleMockApplyFixedReaderResults{err}
return mmApplyFixedReader.mock
}
//Set uses given function f to mock the PayloadReceptacle.ApplyFixedReader method
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) Set(f func(f1 longbits.FixedReader) (err error)) *PayloadReceptacleMock {
if mmApplyFixedReader.defaultExpectation != nil {
mmApplyFixedReader.mock.t.Fatalf("Default expectation is already set for the PayloadReceptacle.ApplyFixedReader method")
}
if len(mmApplyFixedReader.expectations) > 0 {
mmApplyFixedReader.mock.t.Fatalf("Some expectations are already set for the PayloadReceptacle.ApplyFixedReader method")
}
mmApplyFixedReader.mock.funcApplyFixedReader = f
return mmApplyFixedReader.mock
}
// When sets expectation for the PayloadReceptacle.ApplyFixedReader which will trigger the result defined by the following
// Then helper
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) When(f1 longbits.FixedReader) *PayloadReceptacleMockApplyFixedReaderExpectation {
if mmApplyFixedReader.mock.funcApplyFixedReader != nil {
mmApplyFixedReader.mock.t.Fatalf("PayloadReceptacleMock.ApplyFixedReader mock is already set by Set")
}
expectation := &PayloadReceptacleMockApplyFixedReaderExpectation{
mock: mmApplyFixedReader.mock,
params: &PayloadReceptacleMockApplyFixedReaderParams{f1},
}
mmApplyFixedReader.expectations = append(mmApplyFixedReader.expectations, expectation)
return expectation
}
// Then sets up PayloadReceptacle.ApplyFixedReader return parameters for the expectation previously defined by the When method
func (e *PayloadReceptacleMockApplyFixedReaderExpectation) Then(err error) *PayloadReceptacleMock {
e.results = &PayloadReceptacleMockApplyFixedReaderResults{err}
return e.mock
}
// ApplyFixedReader implements PayloadReceptacle
func (mmApplyFixedReader *PayloadReceptacleMock) ApplyFixedReader(f1 longbits.FixedReader) (err error) {
mm_atomic.AddUint64(&mmApplyFixedReader.beforeApplyFixedReaderCounter, 1)
defer mm_atomic.AddUint64(&mmApplyFixedReader.afterApplyFixedReaderCounter, 1)
if mmApplyFixedReader.inspectFuncApplyFixedReader != nil {
mmApplyFixedReader.inspectFuncApplyFixedReader(f1)
}
mm_params := &PayloadReceptacleMockApplyFixedReaderParams{f1}
// Record call args
mmApplyFixedReader.ApplyFixedReaderMock.mutex.Lock()
mmApplyFixedReader.ApplyFixedReaderMock.callArgs = append(mmApplyFixedReader.ApplyFixedReaderMock.callArgs, mm_params)
mmApplyFixedReader.ApplyFixedReaderMock.mutex.Unlock()
for _, e := range mmApplyFixedReader.ApplyFixedReaderMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.err
}
}
if mmApplyFixedReader.ApplyFixedReaderMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmApplyFixedReader.ApplyFixedReaderMock.defaultExpectation.Counter, 1)
mm_want := mmApplyFixedReader.ApplyFixedReaderMock.defaultExpectation.params
mm_got := PayloadReceptacleMockApplyFixedReaderParams{f1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmApplyFixedReader.t.Errorf("PayloadReceptacleMock.ApplyFixedReader got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmApplyFixedReader.ApplyFixedReaderMock.defaultExpectation.results
if mm_results == nil {
mmApplyFixedReader.t.Fatal("No results are set for the PayloadReceptacleMock.ApplyFixedReader")
}
return (*mm_results).err
}
if mmApplyFixedReader.funcApplyFixedReader != nil {
return mmApplyFixedReader.funcApplyFixedReader(f1)
}
mmApplyFixedReader.t.Fatalf("Unexpected call to PayloadReceptacleMock.ApplyFixedReader. %v", f1)
return
}
// ApplyFixedReaderAfterCounter returns a count of finished PayloadReceptacleMock.ApplyFixedReader invocations
func (mmApplyFixedReader *PayloadReceptacleMock) ApplyFixedReaderAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyFixedReader.afterApplyFixedReaderCounter)
}
// ApplyFixedReaderBeforeCounter returns a count of PayloadReceptacleMock.ApplyFixedReader invocations
func (mmApplyFixedReader *PayloadReceptacleMock) ApplyFixedReaderBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyFixedReader.beforeApplyFixedReaderCounter)
}
// Calls returns a list of arguments used in each call to PayloadReceptacleMock.ApplyFixedReader.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmApplyFixedReader *mPayloadReceptacleMockApplyFixedReader) Calls() []*PayloadReceptacleMockApplyFixedReaderParams {
mmApplyFixedReader.mutex.RLock()
argCopy := make([]*PayloadReceptacleMockApplyFixedReaderParams, len(mmApplyFixedReader.callArgs))
copy(argCopy, mmApplyFixedReader.callArgs)
mmApplyFixedReader.mutex.RUnlock()
return argCopy
}
// MinimockApplyFixedReaderDone returns true if the count of the ApplyFixedReader invocations corresponds
// the number of defined expectations
func (m *PayloadReceptacleMock) MinimockApplyFixedReaderDone() bool {
for _, e := range m.ApplyFixedReaderMock.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.ApplyFixedReaderMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyFixedReaderCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcApplyFixedReader != nil && mm_atomic.LoadUint64(&m.afterApplyFixedReaderCounter) < 1 {
return false
}
return true
}
// MinimockApplyFixedReaderInspect logs each unmet expectation
func (m *PayloadReceptacleMock) MinimockApplyFixedReaderInspect() {
for _, e := range m.ApplyFixedReaderMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to PayloadReceptacleMock.ApplyFixedReader with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyFixedReaderMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyFixedReaderCounter) < 1 {
if m.ApplyFixedReaderMock.defaultExpectation.params == nil {
m.t.Error("Expected call to PayloadReceptacleMock.ApplyFixedReader")
} else {
m.t.Errorf("Expected call to PayloadReceptacleMock.ApplyFixedReader with params: %#v", *m.ApplyFixedReaderMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcApplyFixedReader != nil && mm_atomic.LoadUint64(&m.afterApplyFixedReaderCounter) < 1 {
m.t.Error("Expected call to PayloadReceptacleMock.ApplyFixedReader")
}
}
type mPayloadReceptacleMockApplyMarshalTo struct {
mock *PayloadReceptacleMock
defaultExpectation *PayloadReceptacleMockApplyMarshalToExpectation
expectations []*PayloadReceptacleMockApplyMarshalToExpectation
callArgs []*PayloadReceptacleMockApplyMarshalToParams
mutex sync.RWMutex
}
// PayloadReceptacleMockApplyMarshalToExpectation specifies expectation struct of the PayloadReceptacle.ApplyMarshalTo
type PayloadReceptacleMockApplyMarshalToExpectation struct {
mock *PayloadReceptacleMock
params *PayloadReceptacleMockApplyMarshalToParams
results *PayloadReceptacleMockApplyMarshalToResults
Counter uint64
}
// PayloadReceptacleMockApplyMarshalToParams contains parameters of the PayloadReceptacle.ApplyMarshalTo
type PayloadReceptacleMockApplyMarshalToParams struct {
m1 MarshalerTo
}
// PayloadReceptacleMockApplyMarshalToResults contains results of the PayloadReceptacle.ApplyMarshalTo
type PayloadReceptacleMockApplyMarshalToResults struct {
err error
}
// Expect sets up expected params for PayloadReceptacle.ApplyMarshalTo
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) Expect(m1 MarshalerTo) *mPayloadReceptacleMockApplyMarshalTo {
if mmApplyMarshalTo.mock.funcApplyMarshalTo != nil {
mmApplyMarshalTo.mock.t.Fatalf("PayloadReceptacleMock.ApplyMarshalTo mock is already set by Set")
}
if mmApplyMarshalTo.defaultExpectation == nil {
mmApplyMarshalTo.defaultExpectation = &PayloadReceptacleMockApplyMarshalToExpectation{}
}
mmApplyMarshalTo.defaultExpectation.params = &PayloadReceptacleMockApplyMarshalToParams{m1}
for _, e := range mmApplyMarshalTo.expectations {
if minimock.Equal(e.params, mmApplyMarshalTo.defaultExpectation.params) {
mmApplyMarshalTo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmApplyMarshalTo.defaultExpectation.params)
}
}
return mmApplyMarshalTo
}
// Inspect accepts an inspector function that has same arguments as the PayloadReceptacle.ApplyMarshalTo
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) Inspect(f func(m1 MarshalerTo)) *mPayloadReceptacleMockApplyMarshalTo {
if mmApplyMarshalTo.mock.inspectFuncApplyMarshalTo != nil {
mmApplyMarshalTo.mock.t.Fatalf("Inspect function is already set for PayloadReceptacleMock.ApplyMarshalTo")
}
mmApplyMarshalTo.mock.inspectFuncApplyMarshalTo = f
return mmApplyMarshalTo
}
// Return sets up results that will be returned by PayloadReceptacle.ApplyMarshalTo
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) Return(err error) *PayloadReceptacleMock {
if mmApplyMarshalTo.mock.funcApplyMarshalTo != nil {
mmApplyMarshalTo.mock.t.Fatalf("PayloadReceptacleMock.ApplyMarshalTo mock is already set by Set")
}
if mmApplyMarshalTo.defaultExpectation == nil {
mmApplyMarshalTo.defaultExpectation = &PayloadReceptacleMockApplyMarshalToExpectation{mock: mmApplyMarshalTo.mock}
}
mmApplyMarshalTo.defaultExpectation.results = &PayloadReceptacleMockApplyMarshalToResults{err}
return mmApplyMarshalTo.mock
}
//Set uses given function f to mock the PayloadReceptacle.ApplyMarshalTo method
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) Set(f func(m1 MarshalerTo) (err error)) *PayloadReceptacleMock {
if mmApplyMarshalTo.defaultExpectation != nil {
mmApplyMarshalTo.mock.t.Fatalf("Default expectation is already set for the PayloadReceptacle.ApplyMarshalTo method")
}
if len(mmApplyMarshalTo.expectations) > 0 {
mmApplyMarshalTo.mock.t.Fatalf("Some expectations are already set for the PayloadReceptacle.ApplyMarshalTo method")
}
mmApplyMarshalTo.mock.funcApplyMarshalTo = f
return mmApplyMarshalTo.mock
}
// When sets expectation for the PayloadReceptacle.ApplyMarshalTo which will trigger the result defined by the following
// Then helper
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) When(m1 MarshalerTo) *PayloadReceptacleMockApplyMarshalToExpectation {
if mmApplyMarshalTo.mock.funcApplyMarshalTo != nil {
mmApplyMarshalTo.mock.t.Fatalf("PayloadReceptacleMock.ApplyMarshalTo mock is already set by Set")
}
expectation := &PayloadReceptacleMockApplyMarshalToExpectation{
mock: mmApplyMarshalTo.mock,
params: &PayloadReceptacleMockApplyMarshalToParams{m1},
}
mmApplyMarshalTo.expectations = append(mmApplyMarshalTo.expectations, expectation)
return expectation
}
// Then sets up PayloadReceptacle.ApplyMarshalTo return parameters for the expectation previously defined by the When method
func (e *PayloadReceptacleMockApplyMarshalToExpectation) Then(err error) *PayloadReceptacleMock {
e.results = &PayloadReceptacleMockApplyMarshalToResults{err}
return e.mock
}
// ApplyMarshalTo implements PayloadReceptacle
func (mmApplyMarshalTo *PayloadReceptacleMock) ApplyMarshalTo(m1 MarshalerTo) (err error) {
mm_atomic.AddUint64(&mmApplyMarshalTo.beforeApplyMarshalToCounter, 1)
defer mm_atomic.AddUint64(&mmApplyMarshalTo.afterApplyMarshalToCounter, 1)
if mmApplyMarshalTo.inspectFuncApplyMarshalTo != nil {
mmApplyMarshalTo.inspectFuncApplyMarshalTo(m1)
}
mm_params := &PayloadReceptacleMockApplyMarshalToParams{m1}
// Record call args
mmApplyMarshalTo.ApplyMarshalToMock.mutex.Lock()
mmApplyMarshalTo.ApplyMarshalToMock.callArgs = append(mmApplyMarshalTo.ApplyMarshalToMock.callArgs, mm_params)
mmApplyMarshalTo.ApplyMarshalToMock.mutex.Unlock()
for _, e := range mmApplyMarshalTo.ApplyMarshalToMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.err
}
}
if mmApplyMarshalTo.ApplyMarshalToMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmApplyMarshalTo.ApplyMarshalToMock.defaultExpectation.Counter, 1)
mm_want := mmApplyMarshalTo.ApplyMarshalToMock.defaultExpectation.params
mm_got := PayloadReceptacleMockApplyMarshalToParams{m1}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmApplyMarshalTo.t.Errorf("PayloadReceptacleMock.ApplyMarshalTo got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmApplyMarshalTo.ApplyMarshalToMock.defaultExpectation.results
if mm_results == nil {
mmApplyMarshalTo.t.Fatal("No results are set for the PayloadReceptacleMock.ApplyMarshalTo")
}
return (*mm_results).err
}
if mmApplyMarshalTo.funcApplyMarshalTo != nil {
return mmApplyMarshalTo.funcApplyMarshalTo(m1)
}
mmApplyMarshalTo.t.Fatalf("Unexpected call to PayloadReceptacleMock.ApplyMarshalTo. %v", m1)
return
}
// ApplyMarshalToAfterCounter returns a count of finished PayloadReceptacleMock.ApplyMarshalTo invocations
func (mmApplyMarshalTo *PayloadReceptacleMock) ApplyMarshalToAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyMarshalTo.afterApplyMarshalToCounter)
}
// ApplyMarshalToBeforeCounter returns a count of PayloadReceptacleMock.ApplyMarshalTo invocations
func (mmApplyMarshalTo *PayloadReceptacleMock) ApplyMarshalToBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmApplyMarshalTo.beforeApplyMarshalToCounter)
}
// Calls returns a list of arguments used in each call to PayloadReceptacleMock.ApplyMarshalTo.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmApplyMarshalTo *mPayloadReceptacleMockApplyMarshalTo) Calls() []*PayloadReceptacleMockApplyMarshalToParams {
mmApplyMarshalTo.mutex.RLock()
argCopy := make([]*PayloadReceptacleMockApplyMarshalToParams, len(mmApplyMarshalTo.callArgs))
copy(argCopy, mmApplyMarshalTo.callArgs)
mmApplyMarshalTo.mutex.RUnlock()
return argCopy
}
// MinimockApplyMarshalToDone returns true if the count of the ApplyMarshalTo invocations corresponds
// the number of defined expectations
func (m *PayloadReceptacleMock) MinimockApplyMarshalToDone() bool {
for _, e := range m.ApplyMarshalToMock.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.ApplyMarshalToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyMarshalToCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcApplyMarshalTo != nil && mm_atomic.LoadUint64(&m.afterApplyMarshalToCounter) < 1 {
return false
}
return true
}
// MinimockApplyMarshalToInspect logs each unmet expectation
func (m *PayloadReceptacleMock) MinimockApplyMarshalToInspect() {
for _, e := range m.ApplyMarshalToMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to PayloadReceptacleMock.ApplyMarshalTo with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.ApplyMarshalToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterApplyMarshalToCounter) < 1 {
if m.ApplyMarshalToMock.defaultExpectation.params == nil {
m.t.Error("Expected call to PayloadReceptacleMock.ApplyMarshalTo")
} else {
m.t.Errorf("Expected call to PayloadReceptacleMock.ApplyMarshalTo with params: %#v", *m.ApplyMarshalToMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcApplyMarshalTo != nil && mm_atomic.LoadUint64(&m.afterApplyMarshalToCounter) < 1 {
m.t.Error("Expected call to PayloadReceptacleMock.ApplyMarshalTo")
}
}
type mPayloadReceptacleMockWriteTo struct {
mock *PayloadReceptacleMock
defaultExpectation *PayloadReceptacleMockWriteToExpectation
expectations []*PayloadReceptacleMockWriteToExpectation
callArgs []*PayloadReceptacleMockWriteToParams
mutex sync.RWMutex
}
// PayloadReceptacleMockWriteToExpectation specifies expectation struct of the PayloadReceptacle.WriteTo
type PayloadReceptacleMockWriteToExpectation struct {
mock *PayloadReceptacleMock
params *PayloadReceptacleMockWriteToParams
results *PayloadReceptacleMockWriteToResults
Counter uint64
}
// PayloadReceptacleMockWriteToParams contains parameters of the PayloadReceptacle.WriteTo
type PayloadReceptacleMockWriteToParams struct {
w io.Writer
}
// PayloadReceptacleMockWriteToResults contains results of the PayloadReceptacle.WriteTo
type PayloadReceptacleMockWriteToResults struct {
n int64
err error
}
// Expect sets up expected params for PayloadReceptacle.WriteTo
func (mmWriteTo *mPayloadReceptacleMockWriteTo) Expect(w io.Writer) *mPayloadReceptacleMockWriteTo {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("PayloadReceptacleMock.WriteTo mock is already set by Set")
}
if mmWriteTo.defaultExpectation == nil {
mmWriteTo.defaultExpectation = &PayloadReceptacleMockWriteToExpectation{}
}
mmWriteTo.defaultExpectation.params = &PayloadReceptacleMockWriteToParams{w}
for _, e := range mmWriteTo.expectations {
if minimock.Equal(e.params, mmWriteTo.defaultExpectation.params) {
mmWriteTo.mock.t.Fatalf("Expectation set by When has same params: %#v", *mmWriteTo.defaultExpectation.params)
}
}
return mmWriteTo
}
// Inspect accepts an inspector function that has same arguments as the PayloadReceptacle.WriteTo
func (mmWriteTo *mPayloadReceptacleMockWriteTo) Inspect(f func(w io.Writer)) *mPayloadReceptacleMockWriteTo {
if mmWriteTo.mock.inspectFuncWriteTo != nil {
mmWriteTo.mock.t.Fatalf("Inspect function is already set for PayloadReceptacleMock.WriteTo")
}
mmWriteTo.mock.inspectFuncWriteTo = f
return mmWriteTo
}
// Return sets up results that will be returned by PayloadReceptacle.WriteTo
func (mmWriteTo *mPayloadReceptacleMockWriteTo) Return(n int64, err error) *PayloadReceptacleMock {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("PayloadReceptacleMock.WriteTo mock is already set by Set")
}
if mmWriteTo.defaultExpectation == nil {
mmWriteTo.defaultExpectation = &PayloadReceptacleMockWriteToExpectation{mock: mmWriteTo.mock}
}
mmWriteTo.defaultExpectation.results = &PayloadReceptacleMockWriteToResults{n, err}
return mmWriteTo.mock
}
//Set uses given function f to mock the PayloadReceptacle.WriteTo method
func (mmWriteTo *mPayloadReceptacleMockWriteTo) Set(f func(w io.Writer) (n int64, err error)) *PayloadReceptacleMock {
if mmWriteTo.defaultExpectation != nil {
mmWriteTo.mock.t.Fatalf("Default expectation is already set for the PayloadReceptacle.WriteTo method")
}
if len(mmWriteTo.expectations) > 0 {
mmWriteTo.mock.t.Fatalf("Some expectations are already set for the PayloadReceptacle.WriteTo method")
}
mmWriteTo.mock.funcWriteTo = f
return mmWriteTo.mock
}
// When sets expectation for the PayloadReceptacle.WriteTo which will trigger the result defined by the following
// Then helper
func (mmWriteTo *mPayloadReceptacleMockWriteTo) When(w io.Writer) *PayloadReceptacleMockWriteToExpectation {
if mmWriteTo.mock.funcWriteTo != nil {
mmWriteTo.mock.t.Fatalf("PayloadReceptacleMock.WriteTo mock is already set by Set")
}
expectation := &PayloadReceptacleMockWriteToExpectation{
mock: mmWriteTo.mock,
params: &PayloadReceptacleMockWriteToParams{w},
}
mmWriteTo.expectations = append(mmWriteTo.expectations, expectation)
return expectation
}
// Then sets up PayloadReceptacle.WriteTo return parameters for the expectation previously defined by the When method
func (e *PayloadReceptacleMockWriteToExpectation) Then(n int64, err error) *PayloadReceptacleMock {
e.results = &PayloadReceptacleMockWriteToResults{n, err}
return e.mock
}
// WriteTo implements PayloadReceptacle
func (mmWriteTo *PayloadReceptacleMock) WriteTo(w io.Writer) (n int64, err error) {
mm_atomic.AddUint64(&mmWriteTo.beforeWriteToCounter, 1)
defer mm_atomic.AddUint64(&mmWriteTo.afterWriteToCounter, 1)
if mmWriteTo.inspectFuncWriteTo != nil {
mmWriteTo.inspectFuncWriteTo(w)
}
mm_params := &PayloadReceptacleMockWriteToParams{w}
// Record call args
mmWriteTo.WriteToMock.mutex.Lock()
mmWriteTo.WriteToMock.callArgs = append(mmWriteTo.WriteToMock.callArgs, mm_params)
mmWriteTo.WriteToMock.mutex.Unlock()
for _, e := range mmWriteTo.WriteToMock.expectations {
if minimock.Equal(e.params, mm_params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.n, e.results.err
}
}
if mmWriteTo.WriteToMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmWriteTo.WriteToMock.defaultExpectation.Counter, 1)
mm_want := mmWriteTo.WriteToMock.defaultExpectation.params
mm_got := PayloadReceptacleMockWriteToParams{w}
if mm_want != nil && !minimock.Equal(*mm_want, mm_got) {
mmWriteTo.t.Errorf("PayloadReceptacleMock.WriteTo got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got))
}
mm_results := mmWriteTo.WriteToMock.defaultExpectation.results
if mm_results == nil {
mmWriteTo.t.Fatal("No results are set for the PayloadReceptacleMock.WriteTo")
}
return (*mm_results).n, (*mm_results).err
}
if mmWriteTo.funcWriteTo != nil {
return mmWriteTo.funcWriteTo(w)
}
mmWriteTo.t.Fatalf("Unexpected call to PayloadReceptacleMock.WriteTo. %v", w)
return
}
// WriteToAfterCounter returns a count of finished PayloadReceptacleMock.WriteTo invocations
func (mmWriteTo *PayloadReceptacleMock) WriteToAfterCounter() uint64 {
return mm_atomic.LoadUint64(&mmWriteTo.afterWriteToCounter)
}
// WriteToBeforeCounter returns a count of PayloadReceptacleMock.WriteTo invocations
func (mmWriteTo *PayloadReceptacleMock) WriteToBeforeCounter() uint64 {
return mm_atomic.LoadUint64(&mmWriteTo.beforeWriteToCounter)
}
// Calls returns a list of arguments used in each call to PayloadReceptacleMock.WriteTo.
// The list is in the same order as the calls were made (i.e. recent calls have a higher index)
func (mmWriteTo *mPayloadReceptacleMockWriteTo) Calls() []*PayloadReceptacleMockWriteToParams {
mmWriteTo.mutex.RLock()
argCopy := make([]*PayloadReceptacleMockWriteToParams, len(mmWriteTo.callArgs))
copy(argCopy, mmWriteTo.callArgs)
mmWriteTo.mutex.RUnlock()
return argCopy
}
// MinimockWriteToDone returns true if the count of the WriteTo invocations corresponds
// the number of defined expectations
func (m *PayloadReceptacleMock) MinimockWriteToDone() bool {
for _, e := range m.WriteToMock.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.WriteToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
return false
}
// if func was set then invocations count should be greater than zero
if m.funcWriteTo != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
return false
}
return true
}
// MinimockWriteToInspect logs each unmet expectation
func (m *PayloadReceptacleMock) MinimockWriteToInspect() {
for _, e := range m.WriteToMock.expectations {
if mm_atomic.LoadUint64(&e.Counter) < 1 {
m.t.Errorf("Expected call to PayloadReceptacleMock.WriteTo with params: %#v", *e.params)
}
}
// if default expectation was set then invocations count should be greater than zero
if m.WriteToMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
if m.WriteToMock.defaultExpectation.params == nil {
m.t.Error("Expected call to PayloadReceptacleMock.WriteTo")
} else {
m.t.Errorf("Expected call to PayloadReceptacleMock.WriteTo with params: %#v", *m.WriteToMock.defaultExpectation.params)
}
}
// if func was set then invocations count should be greater than zero
if m.funcWriteTo != nil && mm_atomic.LoadUint64(&m.afterWriteToCounter) < 1 {
m.t.Error("Expected call to PayloadReceptacleMock.WriteTo")
}
}
// MinimockFinish checks that all mocked methods have been called the expected number of times
func (m *PayloadReceptacleMock) MinimockFinish() {
if !m.minimockDone() {
m.MinimockApplyFixedReaderInspect()
m.MinimockApplyMarshalToInspect()
m.MinimockWriteToInspect()
m.t.FailNow()
}
}
// MinimockWait waits for all mocked methods to be called the expected number of times
func (m *PayloadReceptacleMock) 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 *PayloadReceptacleMock) minimockDone() bool {
done := true
return done &&
m.MinimockApplyFixedReaderDone() &&
m.MinimockApplyMarshalToDone() &&
m.MinimockWriteToDone()
}