-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock_SubscriptionDriver_test.go
886 lines (813 loc) · 38.5 KB
/
mock_SubscriptionDriver_test.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
// Code generated by github.com/tcard/make.go.mock. DO NOT EDIT.
package pgqueue
import (
context "context"
fmt "fmt"
runtime "runtime"
cmp "github.com/google/go-cmp/cmp"
)
// SubscriptionDriverMocker builds mocks for type SubscriptionDriver.
//
// Its fields match the original type's methods. Set those you expect to be
// called, then call the Mock method to get a mock that implements the original
// type.
//
// If the original type was a function, it is mapped to field Func.
//
// The Describe method is a shortcut to define this struct's fields in a
// declarative manner.
type SubscriptionDriverMocker struct {
FetchPendingDeliveries func(a0 context.Context, a1 func(Delivery)) (r0 error)
InsertSubscription func(a0 context.Context) (r0 error)
ListenForDeliveries func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error)
}
// Describe lets you describe how the methods on the resulting mock are expected
// to be called and what they will return.
//
// When you're done describing methods, call Mock to get a mock that implements
// the behavior you described.
func (m *SubscriptionDriverMocker) Describe() SubscriptionDriverMockDescriptor {
return SubscriptionDriverMockDescriptor{m: m}
}
// A SubscriptionDriverMockDescriptor lets you describe how the methods on the resulting mock are expected
// to be called and what they will return.
//
// When you're done describing methods, call its Mock method to get a mock that
// implements the behavior you described.
type SubscriptionDriverMockDescriptor struct {
m *SubscriptionDriverMocker
descriptors_FetchPendingDeliveries []*SubscriptionDriverFetchPendingDeliveriesMockDescriptor
descriptors_InsertSubscription []*SubscriptionDriverInsertSubscriptionMockDescriptor
descriptors_ListenForDeliveries []*SubscriptionDriverListenForDeliveriesMockDescriptor
}
// Mock returns a mock that the SubscriptionDriver interface, following the behavior
// described by the descriptor methods.
//
// It also returns a function that should be called before the test is done to
// ensure that the expected number of calls to the mock methods happened. You
// can pass a *testing.T to it, since it implements the interface it wants.
func (d SubscriptionDriverMockDescriptor) Mock() (m SubscriptionDriverMock, assert func(t interface {
Errorf(s string, args ...interface{})
}) (ok bool)) {
assert = d.done()
return d.m.Mock(), assert
}
func (d SubscriptionDriverMockDescriptor) done() func(t interface {
Errorf(s string, args ...interface{})
}) bool {
var atAssert []func() (method string, errs []string)
type specErrs struct {
fileLine string
errs []string
}
if len(d.descriptors_FetchPendingDeliveries) > 0 {
for _, desc := range d.descriptors_FetchPendingDeliveries {
desc := desc
calls := 0
prev := desc.call
desc.call = func(a0 context.Context, a1 func(Delivery)) (r0 error) {
calls++
return prev(a0, a1)
}
atAssert = append(atAssert, func() (method string, errs []string) {
err := desc.times(calls)
if err != nil {
return "FetchPendingDeliveries", []string{err.Error()}
}
return "", nil
})
}
d.m.FetchPendingDeliveries = func(a0 context.Context, a1 func(Delivery)) (r0 error) {
var matching []*SubscriptionDriverFetchPendingDeliveriesMockDescriptor
var allErrs []specErrs
for _, desc := range d.descriptors_FetchPendingDeliveries {
errs := desc.argValidator(a0, a1)
if len(errs) > 0 {
allErrs = append(allErrs, specErrs{desc.fileLine, errs})
} else {
matching = append(matching, desc)
}
}
if len(matching) == 1 {
return matching[0].call(a0, a1)
}
var args string
for i, arg := range []interface{}{a0, a1} {
if i != 0 {
args += "\n\t"
}
args += fmt.Sprintf("%#v", arg)
}
if len(matching) == 0 {
matchingErrs := ""
for _, errs := range allErrs {
matchingErrs += "\n\tcandidate described at " + errs.fileLine + ":\n"
for _, err := range errs.errs {
matchingErrs += "\n\t\t" + err
}
}
panic(fmt.Errorf("no matching candidate for call to mock for SubscriptionDriver.FetchPendingDeliveries with args:\n\n\t%+v\n\nfailing candidates:\n%s", args, matchingErrs))
}
matchingLines := ""
for _, m := range matching {
matchingLines += "\n\tcandidate described at " + m.fileLine
}
panic(fmt.Errorf("more than one candidate for call to mock for SubscriptionDriver.FetchPendingDeliveries with args:\n\n\t%+v\n\nmatching candidates:\n%s", args, matchingLines))
}
} else {
d.m.FetchPendingDeliveries = func(a0 context.Context, a1 func(Delivery)) (r0 error) {
panic("unexpected call to mock for SubscriptionDriver.FetchPendingDeliveries")
}
}
if len(d.descriptors_InsertSubscription) > 0 {
for _, desc := range d.descriptors_InsertSubscription {
desc := desc
calls := 0
prev := desc.call
desc.call = func(a0 context.Context) (r0 error) {
calls++
return prev(a0)
}
atAssert = append(atAssert, func() (method string, errs []string) {
err := desc.times(calls)
if err != nil {
return "InsertSubscription", []string{err.Error()}
}
return "", nil
})
}
d.m.InsertSubscription = func(a0 context.Context) (r0 error) {
var matching []*SubscriptionDriverInsertSubscriptionMockDescriptor
var allErrs []specErrs
for _, desc := range d.descriptors_InsertSubscription {
errs := desc.argValidator(a0)
if len(errs) > 0 {
allErrs = append(allErrs, specErrs{desc.fileLine, errs})
} else {
matching = append(matching, desc)
}
}
if len(matching) == 1 {
return matching[0].call(a0)
}
var args string
for i, arg := range []interface{}{a0} {
if i != 0 {
args += "\n\t"
}
args += fmt.Sprintf("%#v", arg)
}
if len(matching) == 0 {
matchingErrs := ""
for _, errs := range allErrs {
matchingErrs += "\n\tcandidate described at " + errs.fileLine + ":\n"
for _, err := range errs.errs {
matchingErrs += "\n\t\t" + err
}
}
panic(fmt.Errorf("no matching candidate for call to mock for SubscriptionDriver.InsertSubscription with args:\n\n\t%+v\n\nfailing candidates:\n%s", args, matchingErrs))
}
matchingLines := ""
for _, m := range matching {
matchingLines += "\n\tcandidate described at " + m.fileLine
}
panic(fmt.Errorf("more than one candidate for call to mock for SubscriptionDriver.InsertSubscription with args:\n\n\t%+v\n\nmatching candidates:\n%s", args, matchingLines))
}
} else {
d.m.InsertSubscription = func(a0 context.Context) (r0 error) {
panic("unexpected call to mock for SubscriptionDriver.InsertSubscription")
}
}
if len(d.descriptors_ListenForDeliveries) > 0 {
for _, desc := range d.descriptors_ListenForDeliveries {
desc := desc
calls := 0
prev := desc.call
desc.call = func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error) {
calls++
return prev(a0)
}
atAssert = append(atAssert, func() (method string, errs []string) {
err := desc.times(calls)
if err != nil {
return "ListenForDeliveries", []string{err.Error()}
}
return "", nil
})
}
d.m.ListenForDeliveries = func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error) {
var matching []*SubscriptionDriverListenForDeliveriesMockDescriptor
var allErrs []specErrs
for _, desc := range d.descriptors_ListenForDeliveries {
errs := desc.argValidator(a0)
if len(errs) > 0 {
allErrs = append(allErrs, specErrs{desc.fileLine, errs})
} else {
matching = append(matching, desc)
}
}
if len(matching) == 1 {
return matching[0].call(a0)
}
var args string
for i, arg := range []interface{}{a0} {
if i != 0 {
args += "\n\t"
}
args += fmt.Sprintf("%#v", arg)
}
if len(matching) == 0 {
matchingErrs := ""
for _, errs := range allErrs {
matchingErrs += "\n\tcandidate described at " + errs.fileLine + ":\n"
for _, err := range errs.errs {
matchingErrs += "\n\t\t" + err
}
}
panic(fmt.Errorf("no matching candidate for call to mock for SubscriptionDriver.ListenForDeliveries with args:\n\n\t%+v\n\nfailing candidates:\n%s", args, matchingErrs))
}
matchingLines := ""
for _, m := range matching {
matchingLines += "\n\tcandidate described at " + m.fileLine
}
panic(fmt.Errorf("more than one candidate for call to mock for SubscriptionDriver.ListenForDeliveries with args:\n\n\t%+v\n\nmatching candidates:\n%s", args, matchingLines))
}
} else {
d.m.ListenForDeliveries = func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error) {
panic("unexpected call to mock for SubscriptionDriver.ListenForDeliveries")
}
}
return func(t interface {
Errorf(s string, args ...interface{})
}) bool {
ok := true
for _, assert := range atAssert {
method, errs := assert()
for _, err := range errs {
ok = false
t.Errorf("mock for SubscriptionDriver.%s: %s", method, err)
}
}
return ok
}
}
// FetchPendingDeliveries starts describing a way method SubscriptionDriver.FetchPendingDeliveries is expected to be called
// and what it should return.
//
// You can call it several times to describe different behaviors, each matching different parameters.
func (d SubscriptionDriverMockDescriptor) FetchPendingDeliveries() *SubscriptionDriverFetchPendingDeliveriesMockDescriptor {
return d.newSubscriptionDriverFetchPendingDeliveriesMockDescriptor()
}
func (d SubscriptionDriverMockDescriptor) newSubscriptionDriverFetchPendingDeliveriesMockDescriptor() *SubscriptionDriverFetchPendingDeliveriesMockDescriptor {
_, file, line, _ := runtime.Caller(2)
return &SubscriptionDriverFetchPendingDeliveriesMockDescriptor{
mockDesc: d,
times: func(int) error { return nil },
argValidator: func(got_a0 context.Context, got_a1 func(Delivery)) []string { return nil },
fileLine: fmt.Sprintf("%s:%d", file, line),
}
}
// SubscriptionDriverFetchPendingDeliveriesMockDescriptor is returned by SubscriptionDriverMockDescriptor.FetchPendingDeliveries and
// holds methods to describe the mock for method SubscriptionDriver.FetchPendingDeliveries.
type SubscriptionDriverFetchPendingDeliveriesMockDescriptor struct {
mockDesc SubscriptionDriverMockDescriptor
times func(int) error
argValidator func(got_a0 context.Context, got_a1 func(Delivery)) []string
call func(a0 context.Context, a1 func(Delivery)) (r0 error)
fileLine string
}
// Takes lets you specify a value with which the actual value passed to
// the mocked method SubscriptionDriver.FetchPendingDeliveries as parameter #1
// will be compared.
//
// Package "github.com/google/go-cmp/cmp" is used to do the comparison. You can
// pass extra options for it.
//
// If you want to accept any value, use TakesAny.
//
// If you want more complex validation logic, use TakesMatching.
func (d *SubscriptionDriverFetchPendingDeliveriesMockDescriptor) Takes(a0 context.Context, opts ...cmp.Option) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context, got_a1 func(Delivery)) []string {
errMsgs := prev(got_a0, got_a1)
if diff := cmp.Diff(a0, got_a0, opts...); diff != "" {
errMsgs = append(errMsgs, "parameter #1 mismatch:\n"+diff)
}
return errMsgs
}
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg{d}
}
// TakesAny declares that any value passed to the mocked method
// FetchPendingDeliveries as parameter #1 is expected.
func (d *SubscriptionDriverFetchPendingDeliveriesMockDescriptor) TakesAny() SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg {
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg{d}
}
// TakesMatching lets you pass a function to accept or reject the actual
// value passed to the mocked method SubscriptionDriver.FetchPendingDeliveries as parameter #1.
func (d *SubscriptionDriverFetchPendingDeliveriesMockDescriptor) TakesMatching(match func(a0 context.Context) error) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context, got_a1 func(Delivery)) []string {
errMsgs := prev(got_a0, got_a1)
if err := match(got_a0); err != nil {
errMsgs = append(errMsgs, "parameter \"a0\" custom matcher error: "+err.Error())
}
return errMsgs
}
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg{d}
}
// SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg is a step forward in the description of a way that the
// method SubscriptionDriver.FetchPendingDeliveries is expected to be called, with 1
// arguments specified.
//
// It has methods to describe the next argument, if there's
// any left, or the return values, if there are any, or the times it's expected
// to be called otherwise.
type SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg struct {
methodDesc *SubscriptionDriverFetchPendingDeliveriesMockDescriptor
}
// And lets you specify a value with which the actual value passed to
// the mocked method SubscriptionDriver.FetchPendingDeliveries as parameter #2
// will be compared.
//
// Package "github.com/google/go-cmp/cmp" is used to do the comparison. You can
// pass extra options for it.
//
// If you want to accept any value, use AndAny.
//
// If you want more complex validation logic, use AndMatching.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg) And(a1 func(Delivery), opts ...cmp.Option) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args {
prev := d.methodDesc.argValidator
d.methodDesc.argValidator = func(got_a0 context.Context, got_a1 func(Delivery)) []string {
errMsgs := prev(got_a0, got_a1)
if diff := cmp.Diff(a1, got_a1, opts...); diff != "" {
errMsgs = append(errMsgs, "parameter #2 mismatch:\n"+diff)
}
return errMsgs
}
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args{d.methodDesc}
}
// AndAny declares that any value passed to the mocked method
// FetchPendingDeliveries as parameter #2 is expected.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg) AndAny() SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args {
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args{d.methodDesc}
}
// AndMatching lets you pass a function to accept or reject the actual
// value passed to the mocked method SubscriptionDriver.FetchPendingDeliveries as parameter #2.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith1Arg) AndMatching(match func(a1 func(Delivery)) error) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args {
prev := d.methodDesc.argValidator
d.methodDesc.argValidator = func(got_a0 context.Context, got_a1 func(Delivery)) []string {
errMsgs := prev(got_a0, got_a1)
if err := match(got_a1); err != nil {
errMsgs = append(errMsgs, "parameter \"a1\" custom matcher error: "+err.Error())
}
return errMsgs
}
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args{d.methodDesc}
}
// SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args is a step forward in the description of a way that the
// method SubscriptionDriver.FetchPendingDeliveries is expected to be called, with 2
// arguments specified.
//
// It has methods to describe the next argument, if there's
// any left, or the return values, if there are any, or the times it's expected
// to be called otherwise.
type SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args struct {
methodDesc *SubscriptionDriverFetchPendingDeliveriesMockDescriptor
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.FetchPendingDeliveries,
// if called with values matching the expectations, will return.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args) Returns(r0 error) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn {
return d.ReturnsFrom(func(context.Context, func(Delivery)) error {
return r0
})
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.FetchPendingDeliveries,
// if called with values matching the expectations, will return.
//
// It passes such passed values to a function that then returns the return values.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWith2Args) ReturnsFrom(f func(a0 context.Context, a1 func(Delivery)) (r0 error)) SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn {
d.methodDesc.call = f
return SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn{d.methodDesc}
}
// SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn is a step forward in the description of a way that
// method SubscriptionDriver.FetchPendingDeliveries is to behave when called, with all expected parameters
// and the resulting values specified.
// arguments specified.
//
// It has methods to describe the times the method is expected to be called,
// or you can start another method call description, or you can call Mock to
// end the description and get the resulting mock.
type SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn struct {
methodDesc *SubscriptionDriverFetchPendingDeliveriesMockDescriptor
}
// Times lets you specify a exact number of times this method is expected to be
// called.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) Times(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got != times {
return fmt.Errorf("expected exactly %d calls, got %d", times, got)
}
return nil
})
}
// AtLeastTimes lets you specify a minimum number of times this method is expected to be
// called.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) AtLeastTimes(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got < times {
return fmt.Errorf("expected at least %d calls, got %d", times, got)
}
return nil
})
}
// TimesMatching lets you pass a function to accept or reject the number of times
// this method has been called.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) TimesMatching(f func(times int) error) SubscriptionDriverMockDescriptor {
d.methodDesc.times = f
d.methodDesc.done()
return d.methodDesc.mockDesc
}
// Mock finishes the description and produces a mock.
//
// See SubscriptionDriverMockDescriptor.Mock for details.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) Mock() (m SubscriptionDriverMock, assert func(t interface{ Errorf(string, ...interface{}) }) (ok bool)) {
d.methodDesc.done()
return d.methodDesc.mockDesc.Mock()
}
// FetchPendingDeliveries finishes the current description for method SubscriptionDriver.FetchPendingDeliveries and
// starts describing for method FetchPendingDeliveries.
//
// See SubscriptionDriverMockDescriptor.FetchPendingDeliveries for details.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) FetchPendingDeliveries() *SubscriptionDriverFetchPendingDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverFetchPendingDeliveriesMockDescriptor()
}
// InsertSubscription finishes the current description for method SubscriptionDriver.FetchPendingDeliveries and
// starts describing for method InsertSubscription.
//
// See SubscriptionDriverMockDescriptor.InsertSubscription for details.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) InsertSubscription() *SubscriptionDriverInsertSubscriptionMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverInsertSubscriptionMockDescriptor()
}
// ListenForDeliveries finishes the current description for method SubscriptionDriver.FetchPendingDeliveries and
// starts describing for method ListenForDeliveries.
//
// See SubscriptionDriverMockDescriptor.ListenForDeliveries for details.
func (d SubscriptionDriverFetchPendingDeliveriesMockDescriptorWithReturn) ListenForDeliveries() *SubscriptionDriverListenForDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverListenForDeliveriesMockDescriptor()
}
func (d *SubscriptionDriverFetchPendingDeliveriesMockDescriptor) done() {
d.mockDesc.descriptors_FetchPendingDeliveries = append(d.mockDesc.descriptors_FetchPendingDeliveries, d)
}
// InsertSubscription starts describing a way method SubscriptionDriver.InsertSubscription is expected to be called
// and what it should return.
//
// You can call it several times to describe different behaviors, each matching different parameters.
func (d SubscriptionDriverMockDescriptor) InsertSubscription() *SubscriptionDriverInsertSubscriptionMockDescriptor {
return d.newSubscriptionDriverInsertSubscriptionMockDescriptor()
}
func (d SubscriptionDriverMockDescriptor) newSubscriptionDriverInsertSubscriptionMockDescriptor() *SubscriptionDriverInsertSubscriptionMockDescriptor {
_, file, line, _ := runtime.Caller(2)
return &SubscriptionDriverInsertSubscriptionMockDescriptor{
mockDesc: d,
times: func(int) error { return nil },
argValidator: func(got_a0 context.Context) []string { return nil },
fileLine: fmt.Sprintf("%s:%d", file, line),
}
}
// SubscriptionDriverInsertSubscriptionMockDescriptor is returned by SubscriptionDriverMockDescriptor.InsertSubscription and
// holds methods to describe the mock for method SubscriptionDriver.InsertSubscription.
type SubscriptionDriverInsertSubscriptionMockDescriptor struct {
mockDesc SubscriptionDriverMockDescriptor
times func(int) error
argValidator func(got_a0 context.Context) []string
call func(a0 context.Context) (r0 error)
fileLine string
}
// Takes lets you specify a value with which the actual value passed to
// the mocked method SubscriptionDriver.InsertSubscription as parameter #1
// will be compared.
//
// Package "github.com/google/go-cmp/cmp" is used to do the comparison. You can
// pass extra options for it.
//
// If you want to accept any value, use TakesAny.
//
// If you want more complex validation logic, use TakesMatching.
func (d *SubscriptionDriverInsertSubscriptionMockDescriptor) Takes(a0 context.Context, opts ...cmp.Option) SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context) []string {
errMsgs := prev(got_a0)
if diff := cmp.Diff(a0, got_a0, opts...); diff != "" {
errMsgs = append(errMsgs, "parameter #1 mismatch:\n"+diff)
}
return errMsgs
}
return SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg{d}
}
// TakesAny declares that any value passed to the mocked method
// InsertSubscription as parameter #1 is expected.
func (d *SubscriptionDriverInsertSubscriptionMockDescriptor) TakesAny() SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg {
return SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg{d}
}
// TakesMatching lets you pass a function to accept or reject the actual
// value passed to the mocked method SubscriptionDriver.InsertSubscription as parameter #1.
func (d *SubscriptionDriverInsertSubscriptionMockDescriptor) TakesMatching(match func(a0 context.Context) error) SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context) []string {
errMsgs := prev(got_a0)
if err := match(got_a0); err != nil {
errMsgs = append(errMsgs, "parameter \"a0\" custom matcher error: "+err.Error())
}
return errMsgs
}
return SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg{d}
}
// SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg is a step forward in the description of a way that the
// method SubscriptionDriver.InsertSubscription is expected to be called, with 1
// arguments specified.
//
// It has methods to describe the next argument, if there's
// any left, or the return values, if there are any, or the times it's expected
// to be called otherwise.
type SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg struct {
methodDesc *SubscriptionDriverInsertSubscriptionMockDescriptor
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.InsertSubscription,
// if called with values matching the expectations, will return.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg) Returns(r0 error) SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn {
return d.ReturnsFrom(func(context.Context) error {
return r0
})
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.InsertSubscription,
// if called with values matching the expectations, will return.
//
// It passes such passed values to a function that then returns the return values.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWith1Arg) ReturnsFrom(f func(a0 context.Context) (r0 error)) SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn {
d.methodDesc.call = f
return SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn{d.methodDesc}
}
// SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn is a step forward in the description of a way that
// method SubscriptionDriver.InsertSubscription is to behave when called, with all expected parameters
// and the resulting values specified.
// arguments specified.
//
// It has methods to describe the times the method is expected to be called,
// or you can start another method call description, or you can call Mock to
// end the description and get the resulting mock.
type SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn struct {
methodDesc *SubscriptionDriverInsertSubscriptionMockDescriptor
}
// Times lets you specify a exact number of times this method is expected to be
// called.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) Times(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got != times {
return fmt.Errorf("expected exactly %d calls, got %d", times, got)
}
return nil
})
}
// AtLeastTimes lets you specify a minimum number of times this method is expected to be
// called.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) AtLeastTimes(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got < times {
return fmt.Errorf("expected at least %d calls, got %d", times, got)
}
return nil
})
}
// TimesMatching lets you pass a function to accept or reject the number of times
// this method has been called.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) TimesMatching(f func(times int) error) SubscriptionDriverMockDescriptor {
d.methodDesc.times = f
d.methodDesc.done()
return d.methodDesc.mockDesc
}
// Mock finishes the description and produces a mock.
//
// See SubscriptionDriverMockDescriptor.Mock for details.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) Mock() (m SubscriptionDriverMock, assert func(t interface{ Errorf(string, ...interface{}) }) (ok bool)) {
d.methodDesc.done()
return d.methodDesc.mockDesc.Mock()
}
// FetchPendingDeliveries finishes the current description for method SubscriptionDriver.InsertSubscription and
// starts describing for method FetchPendingDeliveries.
//
// See SubscriptionDriverMockDescriptor.FetchPendingDeliveries for details.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) FetchPendingDeliveries() *SubscriptionDriverFetchPendingDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverFetchPendingDeliveriesMockDescriptor()
}
// InsertSubscription finishes the current description for method SubscriptionDriver.InsertSubscription and
// starts describing for method InsertSubscription.
//
// See SubscriptionDriverMockDescriptor.InsertSubscription for details.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) InsertSubscription() *SubscriptionDriverInsertSubscriptionMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverInsertSubscriptionMockDescriptor()
}
// ListenForDeliveries finishes the current description for method SubscriptionDriver.InsertSubscription and
// starts describing for method ListenForDeliveries.
//
// See SubscriptionDriverMockDescriptor.ListenForDeliveries for details.
func (d SubscriptionDriverInsertSubscriptionMockDescriptorWithReturn) ListenForDeliveries() *SubscriptionDriverListenForDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverListenForDeliveriesMockDescriptor()
}
func (d *SubscriptionDriverInsertSubscriptionMockDescriptor) done() {
d.mockDesc.descriptors_InsertSubscription = append(d.mockDesc.descriptors_InsertSubscription, d)
}
// ListenForDeliveries starts describing a way method SubscriptionDriver.ListenForDeliveries is expected to be called
// and what it should return.
//
// You can call it several times to describe different behaviors, each matching different parameters.
func (d SubscriptionDriverMockDescriptor) ListenForDeliveries() *SubscriptionDriverListenForDeliveriesMockDescriptor {
return d.newSubscriptionDriverListenForDeliveriesMockDescriptor()
}
func (d SubscriptionDriverMockDescriptor) newSubscriptionDriverListenForDeliveriesMockDescriptor() *SubscriptionDriverListenForDeliveriesMockDescriptor {
_, file, line, _ := runtime.Caller(2)
return &SubscriptionDriverListenForDeliveriesMockDescriptor{
mockDesc: d,
times: func(int) error { return nil },
argValidator: func(got_a0 context.Context) []string { return nil },
fileLine: fmt.Sprintf("%s:%d", file, line),
}
}
// SubscriptionDriverListenForDeliveriesMockDescriptor is returned by SubscriptionDriverMockDescriptor.ListenForDeliveries and
// holds methods to describe the mock for method SubscriptionDriver.ListenForDeliveries.
type SubscriptionDriverListenForDeliveriesMockDescriptor struct {
mockDesc SubscriptionDriverMockDescriptor
times func(int) error
argValidator func(got_a0 context.Context) []string
call func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error)
fileLine string
}
// Takes lets you specify a value with which the actual value passed to
// the mocked method SubscriptionDriver.ListenForDeliveries as parameter #1
// will be compared.
//
// Package "github.com/google/go-cmp/cmp" is used to do the comparison. You can
// pass extra options for it.
//
// If you want to accept any value, use TakesAny.
//
// If you want more complex validation logic, use TakesMatching.
func (d *SubscriptionDriverListenForDeliveriesMockDescriptor) Takes(a0 context.Context, opts ...cmp.Option) SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context) []string {
errMsgs := prev(got_a0)
if diff := cmp.Diff(a0, got_a0, opts...); diff != "" {
errMsgs = append(errMsgs, "parameter #1 mismatch:\n"+diff)
}
return errMsgs
}
return SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg{d}
}
// TakesAny declares that any value passed to the mocked method
// ListenForDeliveries as parameter #1 is expected.
func (d *SubscriptionDriverListenForDeliveriesMockDescriptor) TakesAny() SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg {
return SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg{d}
}
// TakesMatching lets you pass a function to accept or reject the actual
// value passed to the mocked method SubscriptionDriver.ListenForDeliveries as parameter #1.
func (d *SubscriptionDriverListenForDeliveriesMockDescriptor) TakesMatching(match func(a0 context.Context) error) SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg {
prev := d.argValidator
d.argValidator = func(got_a0 context.Context) []string {
errMsgs := prev(got_a0)
if err := match(got_a0); err != nil {
errMsgs = append(errMsgs, "parameter \"a0\" custom matcher error: "+err.Error())
}
return errMsgs
}
return SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg{d}
}
// SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg is a step forward in the description of a way that the
// method SubscriptionDriver.ListenForDeliveries is expected to be called, with 1
// arguments specified.
//
// It has methods to describe the next argument, if there's
// any left, or the return values, if there are any, or the times it's expected
// to be called otherwise.
type SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg struct {
methodDesc *SubscriptionDriverListenForDeliveriesMockDescriptor
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.ListenForDeliveries,
// if called with values matching the expectations, will return.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg) Returns(accept func(context.Context, func(Delivery)) error, close func() error, err error) SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn {
return d.ReturnsFrom(func(context.Context) (func(context.Context, func(Delivery)) error, func() error, error) {
return accept, close, err
})
}
// Returns lets you specify the values that the mocked method SubscriptionDriver.ListenForDeliveries,
// if called with values matching the expectations, will return.
//
// It passes such passed values to a function that then returns the return values.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWith1Arg) ReturnsFrom(f func(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error)) SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn {
d.methodDesc.call = f
return SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn{d.methodDesc}
}
// SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn is a step forward in the description of a way that
// method SubscriptionDriver.ListenForDeliveries is to behave when called, with all expected parameters
// and the resulting values specified.
// arguments specified.
//
// It has methods to describe the times the method is expected to be called,
// or you can start another method call description, or you can call Mock to
// end the description and get the resulting mock.
type SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn struct {
methodDesc *SubscriptionDriverListenForDeliveriesMockDescriptor
}
// Times lets you specify a exact number of times this method is expected to be
// called.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) Times(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got != times {
return fmt.Errorf("expected exactly %d calls, got %d", times, got)
}
return nil
})
}
// AtLeastTimes lets you specify a minimum number of times this method is expected to be
// called.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) AtLeastTimes(times int) SubscriptionDriverMockDescriptor {
return d.TimesMatching(func(got int) error {
if got < times {
return fmt.Errorf("expected at least %d calls, got %d", times, got)
}
return nil
})
}
// TimesMatching lets you pass a function to accept or reject the number of times
// this method has been called.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) TimesMatching(f func(times int) error) SubscriptionDriverMockDescriptor {
d.methodDesc.times = f
d.methodDesc.done()
return d.methodDesc.mockDesc
}
// Mock finishes the description and produces a mock.
//
// See SubscriptionDriverMockDescriptor.Mock for details.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) Mock() (m SubscriptionDriverMock, assert func(t interface{ Errorf(string, ...interface{}) }) (ok bool)) {
d.methodDesc.done()
return d.methodDesc.mockDesc.Mock()
}
// FetchPendingDeliveries finishes the current description for method SubscriptionDriver.ListenForDeliveries and
// starts describing for method FetchPendingDeliveries.
//
// See SubscriptionDriverMockDescriptor.FetchPendingDeliveries for details.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) FetchPendingDeliveries() *SubscriptionDriverFetchPendingDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverFetchPendingDeliveriesMockDescriptor()
}
// InsertSubscription finishes the current description for method SubscriptionDriver.ListenForDeliveries and
// starts describing for method InsertSubscription.
//
// See SubscriptionDriverMockDescriptor.InsertSubscription for details.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) InsertSubscription() *SubscriptionDriverInsertSubscriptionMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverInsertSubscriptionMockDescriptor()
}
// ListenForDeliveries finishes the current description for method SubscriptionDriver.ListenForDeliveries and
// starts describing for method ListenForDeliveries.
//
// See SubscriptionDriverMockDescriptor.ListenForDeliveries for details.
func (d SubscriptionDriverListenForDeliveriesMockDescriptorWithReturn) ListenForDeliveries() *SubscriptionDriverListenForDeliveriesMockDescriptor {
d.methodDesc.done()
return d.methodDesc.mockDesc.newSubscriptionDriverListenForDeliveriesMockDescriptor()
}
func (d *SubscriptionDriverListenForDeliveriesMockDescriptor) done() {
d.mockDesc.descriptors_ListenForDeliveries = append(d.mockDesc.descriptors_ListenForDeliveries, d)
}
// Mock returns a mock for SubscriptionDriver that calls the functions
// defined as struct fields in the receiver.
//
// You probably want to use Describe instead.
func (m *SubscriptionDriverMocker) Mock() SubscriptionDriverMock {
return _makegomock_SubscriptionDriverMockFromMocker{m}
}
type _makegomock_SubscriptionDriverMockFromMocker struct {
m *SubscriptionDriverMocker
}
func (m _makegomock_SubscriptionDriverMockFromMocker) FetchPendingDeliveries(a0 context.Context, a1 func(Delivery)) (r0 error) {
return m.m.FetchPendingDeliveries(a0, a1)
}
func (m _makegomock_SubscriptionDriverMockFromMocker) InsertSubscription(a0 context.Context) (r0 error) {
return m.m.InsertSubscription(a0)
}
func (m _makegomock_SubscriptionDriverMockFromMocker) ListenForDeliveries(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error) {
return m.m.ListenForDeliveries(a0)
}
// SubscriptionDriverMock is a mock with the same underlying type as SubscriptionDriver.
//
// It is copied from the original just to avoid introducing a dependency on
// SubscriptionDriver's package.
type SubscriptionDriverMock interface {
FetchPendingDeliveries(a0 context.Context, a1 func(Delivery)) (r0 error)
InsertSubscription(a0 context.Context) (r0 error)
ListenForDeliveries(a0 context.Context) (accept func(context.Context, func(Delivery)) error, close func() error, err error)
}