1
2
3 package mockdb
4
5 import (
6 "context"
7 "fmt"
8 "reflect"
9 "time"
10
11 kivik "github.com/go-kivik/kivik/v4"
12 "github.com/go-kivik/kivik/v4/driver"
13 )
14
15 var _ = &driver.Attachment{}
16 var _ = reflect.Int
17
18
19 type ExpectedCompact struct {
20 commonExpectation
21 callback func(ctx context.Context) error
22 }
23
24
25
26
27 func (e *ExpectedCompact) WillExecute(cb func(ctx context.Context) error) *ExpectedCompact {
28 e.callback = cb
29 return e
30 }
31
32
33 func (e *ExpectedCompact) WillReturnError(err error) *ExpectedCompact {
34 e.err = err
35 return e
36 }
37
38
39 func (e *ExpectedCompact) WillDelay(delay time.Duration) *ExpectedCompact {
40 e.delay = delay
41 return e
42 }
43
44 func (e *ExpectedCompact) met(_ expectation) bool {
45 return true
46 }
47
48 func (e *ExpectedCompact) method(v bool) string {
49 if !v {
50 return "DB.Compact()"
51 }
52 return fmt.Sprintf("DB(%s).Compact(ctx)", e.dbo().name)
53 }
54
55
56 type ExpectedCompactView struct {
57 commonExpectation
58 callback func(ctx context.Context, arg0 string) error
59 arg0 string
60 }
61
62
63
64
65 func (e *ExpectedCompactView) WillExecute(cb func(ctx context.Context, arg0 string) error) *ExpectedCompactView {
66 e.callback = cb
67 return e
68 }
69
70
71 func (e *ExpectedCompactView) WillReturnError(err error) *ExpectedCompactView {
72 e.err = err
73 return e
74 }
75
76
77 func (e *ExpectedCompactView) WillDelay(delay time.Duration) *ExpectedCompactView {
78 e.delay = delay
79 return e
80 }
81
82 func (e *ExpectedCompactView) met(ex expectation) bool {
83 exp := ex.(*ExpectedCompactView)
84 if exp.arg0 != "" && exp.arg0 != e.arg0 {
85 return false
86 }
87 return true
88 }
89
90 func (e *ExpectedCompactView) method(v bool) string {
91 if !v {
92 return "DB.CompactView()"
93 }
94 arg0 := "?"
95 if e.arg0 != "" {
96 arg0 = fmt.Sprintf("%q", e.arg0)
97 }
98 return fmt.Sprintf("DB(%s).CompactView(ctx, %s)", e.dbo().name, arg0)
99 }
100
101
102 type ExpectedCopy struct {
103 commonExpectation
104 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (string, error)
105 arg0 string
106 arg1 string
107 ret0 string
108 }
109
110
111 func (e *ExpectedCopy) WithOptions(options ...kivik.Option) *ExpectedCopy {
112 e.options = multiOptions{e.options, multiOptions(options)}
113 return e
114 }
115
116
117
118
119 func (e *ExpectedCopy) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (string, error)) *ExpectedCopy {
120 e.callback = cb
121 return e
122 }
123
124
125 func (e *ExpectedCopy) WillReturn(ret0 string) *ExpectedCopy {
126 e.ret0 = ret0
127 return e
128 }
129
130
131 func (e *ExpectedCopy) WillReturnError(err error) *ExpectedCopy {
132 e.err = err
133 return e
134 }
135
136
137 func (e *ExpectedCopy) WillDelay(delay time.Duration) *ExpectedCopy {
138 e.delay = delay
139 return e
140 }
141
142 func (e *ExpectedCopy) met(ex expectation) bool {
143 exp := ex.(*ExpectedCopy)
144 if exp.arg0 != "" && exp.arg0 != e.arg0 {
145 return false
146 }
147 if exp.arg1 != "" && exp.arg1 != e.arg1 {
148 return false
149 }
150 return true
151 }
152
153 func (e *ExpectedCopy) method(v bool) string {
154 if !v {
155 return "DB.Copy()"
156 }
157 arg0, arg1, options := "?", "?", formatOptions(e.options)
158 if e.arg0 != "" {
159 arg0 = fmt.Sprintf("%q", e.arg0)
160 }
161 if e.arg1 != "" {
162 arg1 = fmt.Sprintf("%q", e.arg1)
163 }
164 return fmt.Sprintf("DB(%s).Copy(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
165 }
166
167
168 type ExpectedCreateDoc struct {
169 commonExpectation
170 callback func(ctx context.Context, arg0 interface{}, options driver.Options) (string, string, error)
171 arg0 interface{}
172 ret0 string
173 ret1 string
174 }
175
176
177 func (e *ExpectedCreateDoc) WithOptions(options ...kivik.Option) *ExpectedCreateDoc {
178 e.options = multiOptions{e.options, multiOptions(options)}
179 return e
180 }
181
182
183
184
185 func (e *ExpectedCreateDoc) WillExecute(cb func(ctx context.Context, arg0 interface{}, options driver.Options) (string, string, error)) *ExpectedCreateDoc {
186 e.callback = cb
187 return e
188 }
189
190
191 func (e *ExpectedCreateDoc) WillReturn(ret0 string, ret1 string) *ExpectedCreateDoc {
192 e.ret0 = ret0
193 e.ret1 = ret1
194 return e
195 }
196
197
198 func (e *ExpectedCreateDoc) WillReturnError(err error) *ExpectedCreateDoc {
199 e.err = err
200 return e
201 }
202
203
204 func (e *ExpectedCreateDoc) WillDelay(delay time.Duration) *ExpectedCreateDoc {
205 e.delay = delay
206 return e
207 }
208
209 func (e *ExpectedCreateDoc) met(ex expectation) bool {
210 exp := ex.(*ExpectedCreateDoc)
211 if exp.arg0 != nil && !jsonMeets(exp.arg0, e.arg0) {
212 return false
213 }
214 return true
215 }
216
217 func (e *ExpectedCreateDoc) method(v bool) string {
218 if !v {
219 return "DB.CreateDoc()"
220 }
221 arg0, options := "?", formatOptions(e.options)
222 if e.arg0 != nil {
223 arg0 = fmt.Sprintf("%v", e.arg0)
224 }
225 return fmt.Sprintf("DB(%s).CreateDoc(ctx, %s, %s)", e.dbo().name, arg0, options)
226 }
227
228
229 type ExpectedCreateIndex struct {
230 commonExpectation
231 callback func(ctx context.Context, arg0 string, arg1 string, arg2 interface{}, options driver.Options) error
232 arg0 string
233 arg1 string
234 arg2 interface{}
235 }
236
237
238 func (e *ExpectedCreateIndex) WithOptions(options ...kivik.Option) *ExpectedCreateIndex {
239 e.options = multiOptions{e.options, multiOptions(options)}
240 return e
241 }
242
243
244
245
246 func (e *ExpectedCreateIndex) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, arg2 interface{}, options driver.Options) error) *ExpectedCreateIndex {
247 e.callback = cb
248 return e
249 }
250
251
252 func (e *ExpectedCreateIndex) WillReturnError(err error) *ExpectedCreateIndex {
253 e.err = err
254 return e
255 }
256
257
258 func (e *ExpectedCreateIndex) WillDelay(delay time.Duration) *ExpectedCreateIndex {
259 e.delay = delay
260 return e
261 }
262
263 func (e *ExpectedCreateIndex) met(ex expectation) bool {
264 exp := ex.(*ExpectedCreateIndex)
265 if exp.arg0 != "" && exp.arg0 != e.arg0 {
266 return false
267 }
268 if exp.arg1 != "" && exp.arg1 != e.arg1 {
269 return false
270 }
271 if exp.arg2 != nil && !jsonMeets(exp.arg2, e.arg2) {
272 return false
273 }
274 return true
275 }
276
277 func (e *ExpectedCreateIndex) method(v bool) string {
278 if !v {
279 return "DB.CreateIndex()"
280 }
281 arg0, arg1, arg2, options := "?", "?", "?", formatOptions(e.options)
282 if e.arg0 != "" {
283 arg0 = fmt.Sprintf("%q", e.arg0)
284 }
285 if e.arg1 != "" {
286 arg1 = fmt.Sprintf("%q", e.arg1)
287 }
288 if e.arg2 != nil {
289 arg2 = fmt.Sprintf("%v", e.arg2)
290 }
291 return fmt.Sprintf("DB(%s).CreateIndex(ctx, %s, %s, %s, %s)", e.dbo().name, arg0, arg1, arg2, options)
292 }
293
294
295 type ExpectedDeleteIndex struct {
296 commonExpectation
297 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) error
298 arg0 string
299 arg1 string
300 }
301
302
303 func (e *ExpectedDeleteIndex) WithOptions(options ...kivik.Option) *ExpectedDeleteIndex {
304 e.options = multiOptions{e.options, multiOptions(options)}
305 return e
306 }
307
308
309
310
311 func (e *ExpectedDeleteIndex) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) error) *ExpectedDeleteIndex {
312 e.callback = cb
313 return e
314 }
315
316
317 func (e *ExpectedDeleteIndex) WillReturnError(err error) *ExpectedDeleteIndex {
318 e.err = err
319 return e
320 }
321
322
323 func (e *ExpectedDeleteIndex) WillDelay(delay time.Duration) *ExpectedDeleteIndex {
324 e.delay = delay
325 return e
326 }
327
328 func (e *ExpectedDeleteIndex) met(ex expectation) bool {
329 exp := ex.(*ExpectedDeleteIndex)
330 if exp.arg0 != "" && exp.arg0 != e.arg0 {
331 return false
332 }
333 if exp.arg1 != "" && exp.arg1 != e.arg1 {
334 return false
335 }
336 return true
337 }
338
339 func (e *ExpectedDeleteIndex) method(v bool) string {
340 if !v {
341 return "DB.DeleteIndex()"
342 }
343 arg0, arg1, options := "?", "?", formatOptions(e.options)
344 if e.arg0 != "" {
345 arg0 = fmt.Sprintf("%q", e.arg0)
346 }
347 if e.arg1 != "" {
348 arg1 = fmt.Sprintf("%q", e.arg1)
349 }
350 return fmt.Sprintf("DB(%s).DeleteIndex(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
351 }
352
353
354 type ExpectedFlush struct {
355 commonExpectation
356 callback func(ctx context.Context) error
357 }
358
359
360
361
362 func (e *ExpectedFlush) WillExecute(cb func(ctx context.Context) error) *ExpectedFlush {
363 e.callback = cb
364 return e
365 }
366
367
368 func (e *ExpectedFlush) WillReturnError(err error) *ExpectedFlush {
369 e.err = err
370 return e
371 }
372
373
374 func (e *ExpectedFlush) WillDelay(delay time.Duration) *ExpectedFlush {
375 e.delay = delay
376 return e
377 }
378
379 func (e *ExpectedFlush) met(_ expectation) bool {
380 return true
381 }
382
383 func (e *ExpectedFlush) method(v bool) string {
384 if !v {
385 return "DB.Flush()"
386 }
387 return fmt.Sprintf("DB(%s).Flush(ctx)", e.dbo().name)
388 }
389
390
391 type ExpectedGetRev struct {
392 commonExpectation
393 callback func(ctx context.Context, arg0 string, options driver.Options) (string, error)
394 arg0 string
395 ret0 string
396 }
397
398
399 func (e *ExpectedGetRev) WithOptions(options ...kivik.Option) *ExpectedGetRev {
400 e.options = multiOptions{e.options, multiOptions(options)}
401 return e
402 }
403
404
405
406
407 func (e *ExpectedGetRev) WillExecute(cb func(ctx context.Context, arg0 string, options driver.Options) (string, error)) *ExpectedGetRev {
408 e.callback = cb
409 return e
410 }
411
412
413 func (e *ExpectedGetRev) WillReturn(ret0 string) *ExpectedGetRev {
414 e.ret0 = ret0
415 return e
416 }
417
418
419 func (e *ExpectedGetRev) WillReturnError(err error) *ExpectedGetRev {
420 e.err = err
421 return e
422 }
423
424
425 func (e *ExpectedGetRev) WillDelay(delay time.Duration) *ExpectedGetRev {
426 e.delay = delay
427 return e
428 }
429
430 func (e *ExpectedGetRev) met(ex expectation) bool {
431 exp := ex.(*ExpectedGetRev)
432 if exp.arg0 != "" && exp.arg0 != e.arg0 {
433 return false
434 }
435 return true
436 }
437
438 func (e *ExpectedGetRev) method(v bool) string {
439 if !v {
440 return "DB.GetRev()"
441 }
442 arg0, options := "?", formatOptions(e.options)
443 if e.arg0 != "" {
444 arg0 = fmt.Sprintf("%q", e.arg0)
445 }
446 return fmt.Sprintf("DB(%s).GetRev(ctx, %s, %s)", e.dbo().name, arg0, options)
447 }
448
449
450 type ExpectedPut struct {
451 commonExpectation
452 callback func(ctx context.Context, arg0 string, arg1 interface{}, options driver.Options) (string, error)
453 arg0 string
454 arg1 interface{}
455 ret0 string
456 }
457
458
459 func (e *ExpectedPut) WithOptions(options ...kivik.Option) *ExpectedPut {
460 e.options = multiOptions{e.options, multiOptions(options)}
461 return e
462 }
463
464
465
466
467 func (e *ExpectedPut) WillExecute(cb func(ctx context.Context, arg0 string, arg1 interface{}, options driver.Options) (string, error)) *ExpectedPut {
468 e.callback = cb
469 return e
470 }
471
472
473 func (e *ExpectedPut) WillReturn(ret0 string) *ExpectedPut {
474 e.ret0 = ret0
475 return e
476 }
477
478
479 func (e *ExpectedPut) WillReturnError(err error) *ExpectedPut {
480 e.err = err
481 return e
482 }
483
484
485 func (e *ExpectedPut) WillDelay(delay time.Duration) *ExpectedPut {
486 e.delay = delay
487 return e
488 }
489
490 func (e *ExpectedPut) met(ex expectation) bool {
491 exp := ex.(*ExpectedPut)
492 if exp.arg0 != "" && exp.arg0 != e.arg0 {
493 return false
494 }
495 if exp.arg1 != nil && !jsonMeets(exp.arg1, e.arg1) {
496 return false
497 }
498 return true
499 }
500
501 func (e *ExpectedPut) method(v bool) string {
502 if !v {
503 return "DB.Put()"
504 }
505 arg0, arg1, options := "?", "?", formatOptions(e.options)
506 if e.arg0 != "" {
507 arg0 = fmt.Sprintf("%q", e.arg0)
508 }
509 if e.arg1 != nil {
510 arg1 = fmt.Sprintf("%v", e.arg1)
511 }
512 return fmt.Sprintf("DB(%s).Put(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
513 }
514
515
516 type ExpectedViewCleanup struct {
517 commonExpectation
518 callback func(ctx context.Context) error
519 }
520
521
522
523
524 func (e *ExpectedViewCleanup) WillExecute(cb func(ctx context.Context) error) *ExpectedViewCleanup {
525 e.callback = cb
526 return e
527 }
528
529
530 func (e *ExpectedViewCleanup) WillReturnError(err error) *ExpectedViewCleanup {
531 e.err = err
532 return e
533 }
534
535
536 func (e *ExpectedViewCleanup) WillDelay(delay time.Duration) *ExpectedViewCleanup {
537 e.delay = delay
538 return e
539 }
540
541 func (e *ExpectedViewCleanup) met(_ expectation) bool {
542 return true
543 }
544
545 func (e *ExpectedViewCleanup) method(v bool) string {
546 if !v {
547 return "DB.ViewCleanup()"
548 }
549 return fmt.Sprintf("DB(%s).ViewCleanup(ctx)", e.dbo().name)
550 }
551
552
553 type ExpectedAllDocs struct {
554 commonExpectation
555 callback func(ctx context.Context, options driver.Options) (driver.Rows, error)
556 ret0 *Rows
557 }
558
559
560 func (e *ExpectedAllDocs) WithOptions(options ...kivik.Option) *ExpectedAllDocs {
561 e.options = multiOptions{e.options, multiOptions(options)}
562 return e
563 }
564
565
566
567
568 func (e *ExpectedAllDocs) WillExecute(cb func(ctx context.Context, options driver.Options) (driver.Rows, error)) *ExpectedAllDocs {
569 e.callback = cb
570 return e
571 }
572
573
574 func (e *ExpectedAllDocs) WillReturn(ret0 *Rows) *ExpectedAllDocs {
575 e.ret0 = ret0
576 return e
577 }
578
579
580 func (e *ExpectedAllDocs) WillReturnError(err error) *ExpectedAllDocs {
581 e.err = err
582 return e
583 }
584
585
586 func (e *ExpectedAllDocs) WillDelay(delay time.Duration) *ExpectedAllDocs {
587 e.delay = delay
588 return e
589 }
590
591 func (e *ExpectedAllDocs) met(_ expectation) bool {
592 return true
593 }
594
595 func (e *ExpectedAllDocs) method(v bool) string {
596 if !v {
597 return "DB.AllDocs()"
598 }
599 options := formatOptions(e.options)
600 return fmt.Sprintf("DB(%s).AllDocs(ctx, %s)", e.dbo().name, options)
601 }
602
603
604 type ExpectedBulkDocs struct {
605 commonExpectation
606 callback func(ctx context.Context, arg0 []interface{}, options driver.Options) ([]driver.BulkResult, error)
607 arg0 []interface{}
608 ret0 []driver.BulkResult
609 }
610
611
612 func (e *ExpectedBulkDocs) WithOptions(options ...kivik.Option) *ExpectedBulkDocs {
613 e.options = multiOptions{e.options, multiOptions(options)}
614 return e
615 }
616
617
618
619
620 func (e *ExpectedBulkDocs) WillExecute(cb func(ctx context.Context, arg0 []interface{}, options driver.Options) ([]driver.BulkResult, error)) *ExpectedBulkDocs {
621 e.callback = cb
622 return e
623 }
624
625
626 func (e *ExpectedBulkDocs) WillReturn(ret0 []driver.BulkResult) *ExpectedBulkDocs {
627 e.ret0 = ret0
628 return e
629 }
630
631
632 func (e *ExpectedBulkDocs) WillReturnError(err error) *ExpectedBulkDocs {
633 e.err = err
634 return e
635 }
636
637
638 func (e *ExpectedBulkDocs) WillDelay(delay time.Duration) *ExpectedBulkDocs {
639 e.delay = delay
640 return e
641 }
642
643 func (e *ExpectedBulkDocs) met(ex expectation) bool {
644 exp := ex.(*ExpectedBulkDocs)
645 if exp.arg0 != nil && !reflect.DeepEqual(exp.arg0, e.arg0) {
646 return false
647 }
648 return true
649 }
650
651 func (e *ExpectedBulkDocs) method(v bool) string {
652 if !v {
653 return "DB.BulkDocs()"
654 }
655 arg0, options := "?", formatOptions(e.options)
656 if e.arg0 != nil {
657 arg0 = fmt.Sprintf("%v", e.arg0)
658 }
659 return fmt.Sprintf("DB(%s).BulkDocs(ctx, %s, %s)", e.dbo().name, arg0, options)
660 }
661
662
663 type ExpectedBulkGet struct {
664 commonExpectation
665 callback func(ctx context.Context, arg0 []driver.BulkGetReference, options driver.Options) (driver.Rows, error)
666 arg0 []driver.BulkGetReference
667 ret0 *Rows
668 }
669
670
671 func (e *ExpectedBulkGet) WithOptions(options ...kivik.Option) *ExpectedBulkGet {
672 e.options = multiOptions{e.options, multiOptions(options)}
673 return e
674 }
675
676
677
678
679 func (e *ExpectedBulkGet) WillExecute(cb func(ctx context.Context, arg0 []driver.BulkGetReference, options driver.Options) (driver.Rows, error)) *ExpectedBulkGet {
680 e.callback = cb
681 return e
682 }
683
684
685 func (e *ExpectedBulkGet) WillReturn(ret0 *Rows) *ExpectedBulkGet {
686 e.ret0 = ret0
687 return e
688 }
689
690
691 func (e *ExpectedBulkGet) WillReturnError(err error) *ExpectedBulkGet {
692 e.err = err
693 return e
694 }
695
696
697 func (e *ExpectedBulkGet) WillDelay(delay time.Duration) *ExpectedBulkGet {
698 e.delay = delay
699 return e
700 }
701
702 func (e *ExpectedBulkGet) met(ex expectation) bool {
703 exp := ex.(*ExpectedBulkGet)
704 if exp.arg0 != nil && !reflect.DeepEqual(exp.arg0, e.arg0) {
705 return false
706 }
707 return true
708 }
709
710 func (e *ExpectedBulkGet) method(v bool) string {
711 if !v {
712 return "DB.BulkGet()"
713 }
714 arg0, options := "?", formatOptions(e.options)
715 if e.arg0 != nil {
716 arg0 = fmt.Sprintf("%v", e.arg0)
717 }
718 return fmt.Sprintf("DB(%s).BulkGet(ctx, %s, %s)", e.dbo().name, arg0, options)
719 }
720
721
722 type ExpectedChanges struct {
723 commonExpectation
724 callback func(ctx context.Context, options driver.Options) (driver.Changes, error)
725 ret0 *Changes
726 }
727
728
729 func (e *ExpectedChanges) WithOptions(options ...kivik.Option) *ExpectedChanges {
730 e.options = multiOptions{e.options, multiOptions(options)}
731 return e
732 }
733
734
735
736
737 func (e *ExpectedChanges) WillExecute(cb func(ctx context.Context, options driver.Options) (driver.Changes, error)) *ExpectedChanges {
738 e.callback = cb
739 return e
740 }
741
742
743 func (e *ExpectedChanges) WillReturn(ret0 *Changes) *ExpectedChanges {
744 e.ret0 = ret0
745 return e
746 }
747
748
749 func (e *ExpectedChanges) WillReturnError(err error) *ExpectedChanges {
750 e.err = err
751 return e
752 }
753
754
755 func (e *ExpectedChanges) WillDelay(delay time.Duration) *ExpectedChanges {
756 e.delay = delay
757 return e
758 }
759
760 func (e *ExpectedChanges) met(_ expectation) bool {
761 return true
762 }
763
764 func (e *ExpectedChanges) method(v bool) string {
765 if !v {
766 return "DB.Changes()"
767 }
768 options := formatOptions(e.options)
769 return fmt.Sprintf("DB(%s).Changes(ctx, %s)", e.dbo().name, options)
770 }
771
772
773 type ExpectedDelete struct {
774 commonExpectation
775 callback func(ctx context.Context, arg0 string, options driver.Options) (string, error)
776 arg0 string
777 ret0 string
778 }
779
780
781 func (e *ExpectedDelete) WithOptions(options ...kivik.Option) *ExpectedDelete {
782 e.options = multiOptions{e.options, multiOptions(options)}
783 return e
784 }
785
786
787
788
789 func (e *ExpectedDelete) WillExecute(cb func(ctx context.Context, arg0 string, options driver.Options) (string, error)) *ExpectedDelete {
790 e.callback = cb
791 return e
792 }
793
794
795 func (e *ExpectedDelete) WillReturn(ret0 string) *ExpectedDelete {
796 e.ret0 = ret0
797 return e
798 }
799
800
801 func (e *ExpectedDelete) WillReturnError(err error) *ExpectedDelete {
802 e.err = err
803 return e
804 }
805
806
807 func (e *ExpectedDelete) WillDelay(delay time.Duration) *ExpectedDelete {
808 e.delay = delay
809 return e
810 }
811
812 func (e *ExpectedDelete) met(ex expectation) bool {
813 exp := ex.(*ExpectedDelete)
814 if exp.arg0 != "" && exp.arg0 != e.arg0 {
815 return false
816 }
817 return true
818 }
819
820 func (e *ExpectedDelete) method(v bool) string {
821 if !v {
822 return "DB.Delete()"
823 }
824 arg0, options := "?", formatOptions(e.options)
825 if e.arg0 != "" {
826 arg0 = fmt.Sprintf("%q", e.arg0)
827 }
828 return fmt.Sprintf("DB(%s).Delete(ctx, %s, %s)", e.dbo().name, arg0, options)
829 }
830
831
832 type ExpectedDeleteAttachment struct {
833 commonExpectation
834 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (string, error)
835 arg0 string
836 arg1 string
837 ret0 string
838 }
839
840
841 func (e *ExpectedDeleteAttachment) WithOptions(options ...kivik.Option) *ExpectedDeleteAttachment {
842 e.options = multiOptions{e.options, multiOptions(options)}
843 return e
844 }
845
846
847
848
849 func (e *ExpectedDeleteAttachment) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (string, error)) *ExpectedDeleteAttachment {
850 e.callback = cb
851 return e
852 }
853
854
855 func (e *ExpectedDeleteAttachment) WillReturn(ret0 string) *ExpectedDeleteAttachment {
856 e.ret0 = ret0
857 return e
858 }
859
860
861 func (e *ExpectedDeleteAttachment) WillReturnError(err error) *ExpectedDeleteAttachment {
862 e.err = err
863 return e
864 }
865
866
867 func (e *ExpectedDeleteAttachment) WillDelay(delay time.Duration) *ExpectedDeleteAttachment {
868 e.delay = delay
869 return e
870 }
871
872 func (e *ExpectedDeleteAttachment) met(ex expectation) bool {
873 exp := ex.(*ExpectedDeleteAttachment)
874 if exp.arg0 != "" && exp.arg0 != e.arg0 {
875 return false
876 }
877 if exp.arg1 != "" && exp.arg1 != e.arg1 {
878 return false
879 }
880 return true
881 }
882
883 func (e *ExpectedDeleteAttachment) method(v bool) string {
884 if !v {
885 return "DB.DeleteAttachment()"
886 }
887 arg0, arg1, options := "?", "?", formatOptions(e.options)
888 if e.arg0 != "" {
889 arg0 = fmt.Sprintf("%q", e.arg0)
890 }
891 if e.arg1 != "" {
892 arg1 = fmt.Sprintf("%q", e.arg1)
893 }
894 return fmt.Sprintf("DB(%s).DeleteAttachment(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
895 }
896
897
898 type ExpectedDesignDocs struct {
899 commonExpectation
900 callback func(ctx context.Context, options driver.Options) (driver.Rows, error)
901 ret0 *Rows
902 }
903
904
905 func (e *ExpectedDesignDocs) WithOptions(options ...kivik.Option) *ExpectedDesignDocs {
906 e.options = multiOptions{e.options, multiOptions(options)}
907 return e
908 }
909
910
911
912
913 func (e *ExpectedDesignDocs) WillExecute(cb func(ctx context.Context, options driver.Options) (driver.Rows, error)) *ExpectedDesignDocs {
914 e.callback = cb
915 return e
916 }
917
918
919 func (e *ExpectedDesignDocs) WillReturn(ret0 *Rows) *ExpectedDesignDocs {
920 e.ret0 = ret0
921 return e
922 }
923
924
925 func (e *ExpectedDesignDocs) WillReturnError(err error) *ExpectedDesignDocs {
926 e.err = err
927 return e
928 }
929
930
931 func (e *ExpectedDesignDocs) WillDelay(delay time.Duration) *ExpectedDesignDocs {
932 e.delay = delay
933 return e
934 }
935
936 func (e *ExpectedDesignDocs) met(_ expectation) bool {
937 return true
938 }
939
940 func (e *ExpectedDesignDocs) method(v bool) string {
941 if !v {
942 return "DB.DesignDocs()"
943 }
944 options := formatOptions(e.options)
945 return fmt.Sprintf("DB(%s).DesignDocs(ctx, %s)", e.dbo().name, options)
946 }
947
948
949 type ExpectedExplain struct {
950 commonExpectation
951 callback func(ctx context.Context, arg0 interface{}, options driver.Options) (*driver.QueryPlan, error)
952 arg0 interface{}
953 ret0 *driver.QueryPlan
954 }
955
956
957 func (e *ExpectedExplain) WithOptions(options ...kivik.Option) *ExpectedExplain {
958 e.options = multiOptions{e.options, multiOptions(options)}
959 return e
960 }
961
962
963
964
965 func (e *ExpectedExplain) WillExecute(cb func(ctx context.Context, arg0 interface{}, options driver.Options) (*driver.QueryPlan, error)) *ExpectedExplain {
966 e.callback = cb
967 return e
968 }
969
970
971 func (e *ExpectedExplain) WillReturn(ret0 *driver.QueryPlan) *ExpectedExplain {
972 e.ret0 = ret0
973 return e
974 }
975
976
977 func (e *ExpectedExplain) WillReturnError(err error) *ExpectedExplain {
978 e.err = err
979 return e
980 }
981
982
983 func (e *ExpectedExplain) WillDelay(delay time.Duration) *ExpectedExplain {
984 e.delay = delay
985 return e
986 }
987
988 func (e *ExpectedExplain) met(ex expectation) bool {
989 exp := ex.(*ExpectedExplain)
990 if exp.arg0 != nil && !jsonMeets(exp.arg0, e.arg0) {
991 return false
992 }
993 return true
994 }
995
996 func (e *ExpectedExplain) method(v bool) string {
997 if !v {
998 return "DB.Explain()"
999 }
1000 arg0, options := "?", formatOptions(e.options)
1001 if e.arg0 != nil {
1002 arg0 = fmt.Sprintf("%v", e.arg0)
1003 }
1004 return fmt.Sprintf("DB(%s).Explain(ctx, %s, %s)", e.dbo().name, arg0, options)
1005 }
1006
1007
1008 type ExpectedFind struct {
1009 commonExpectation
1010 callback func(ctx context.Context, arg0 interface{}, options driver.Options) (driver.Rows, error)
1011 arg0 interface{}
1012 ret0 *Rows
1013 }
1014
1015
1016 func (e *ExpectedFind) WithOptions(options ...kivik.Option) *ExpectedFind {
1017 e.options = multiOptions{e.options, multiOptions(options)}
1018 return e
1019 }
1020
1021
1022
1023
1024 func (e *ExpectedFind) WillExecute(cb func(ctx context.Context, arg0 interface{}, options driver.Options) (driver.Rows, error)) *ExpectedFind {
1025 e.callback = cb
1026 return e
1027 }
1028
1029
1030 func (e *ExpectedFind) WillReturn(ret0 *Rows) *ExpectedFind {
1031 e.ret0 = ret0
1032 return e
1033 }
1034
1035
1036 func (e *ExpectedFind) WillReturnError(err error) *ExpectedFind {
1037 e.err = err
1038 return e
1039 }
1040
1041
1042 func (e *ExpectedFind) WillDelay(delay time.Duration) *ExpectedFind {
1043 e.delay = delay
1044 return e
1045 }
1046
1047 func (e *ExpectedFind) met(ex expectation) bool {
1048 exp := ex.(*ExpectedFind)
1049 if exp.arg0 != nil && !jsonMeets(exp.arg0, e.arg0) {
1050 return false
1051 }
1052 return true
1053 }
1054
1055 func (e *ExpectedFind) method(v bool) string {
1056 if !v {
1057 return "DB.Find()"
1058 }
1059 arg0, options := "?", formatOptions(e.options)
1060 if e.arg0 != nil {
1061 arg0 = fmt.Sprintf("%v", e.arg0)
1062 }
1063 return fmt.Sprintf("DB(%s).Find(ctx, %s, %s)", e.dbo().name, arg0, options)
1064 }
1065
1066
1067 type ExpectedGet struct {
1068 commonExpectation
1069 callback func(ctx context.Context, arg0 string, options driver.Options) (*driver.Document, error)
1070 arg0 string
1071 ret0 *driver.Document
1072 }
1073
1074
1075 func (e *ExpectedGet) WithOptions(options ...kivik.Option) *ExpectedGet {
1076 e.options = multiOptions{e.options, multiOptions(options)}
1077 return e
1078 }
1079
1080
1081
1082
1083 func (e *ExpectedGet) WillExecute(cb func(ctx context.Context, arg0 string, options driver.Options) (*driver.Document, error)) *ExpectedGet {
1084 e.callback = cb
1085 return e
1086 }
1087
1088
1089 func (e *ExpectedGet) WillReturn(ret0 *driver.Document) *ExpectedGet {
1090 e.ret0 = ret0
1091 return e
1092 }
1093
1094
1095 func (e *ExpectedGet) WillReturnError(err error) *ExpectedGet {
1096 e.err = err
1097 return e
1098 }
1099
1100
1101 func (e *ExpectedGet) WillDelay(delay time.Duration) *ExpectedGet {
1102 e.delay = delay
1103 return e
1104 }
1105
1106 func (e *ExpectedGet) met(ex expectation) bool {
1107 exp := ex.(*ExpectedGet)
1108 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1109 return false
1110 }
1111 return true
1112 }
1113
1114 func (e *ExpectedGet) method(v bool) string {
1115 if !v {
1116 return "DB.Get()"
1117 }
1118 arg0, options := "?", formatOptions(e.options)
1119 if e.arg0 != "" {
1120 arg0 = fmt.Sprintf("%q", e.arg0)
1121 }
1122 return fmt.Sprintf("DB(%s).Get(ctx, %s, %s)", e.dbo().name, arg0, options)
1123 }
1124
1125
1126 type ExpectedGetAttachment struct {
1127 commonExpectation
1128 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (*driver.Attachment, error)
1129 arg0 string
1130 arg1 string
1131 ret0 *driver.Attachment
1132 }
1133
1134
1135 func (e *ExpectedGetAttachment) WithOptions(options ...kivik.Option) *ExpectedGetAttachment {
1136 e.options = multiOptions{e.options, multiOptions(options)}
1137 return e
1138 }
1139
1140
1141
1142
1143 func (e *ExpectedGetAttachment) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (*driver.Attachment, error)) *ExpectedGetAttachment {
1144 e.callback = cb
1145 return e
1146 }
1147
1148
1149 func (e *ExpectedGetAttachment) WillReturn(ret0 *driver.Attachment) *ExpectedGetAttachment {
1150 e.ret0 = ret0
1151 return e
1152 }
1153
1154
1155 func (e *ExpectedGetAttachment) WillReturnError(err error) *ExpectedGetAttachment {
1156 e.err = err
1157 return e
1158 }
1159
1160
1161 func (e *ExpectedGetAttachment) WillDelay(delay time.Duration) *ExpectedGetAttachment {
1162 e.delay = delay
1163 return e
1164 }
1165
1166 func (e *ExpectedGetAttachment) met(ex expectation) bool {
1167 exp := ex.(*ExpectedGetAttachment)
1168 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1169 return false
1170 }
1171 if exp.arg1 != "" && exp.arg1 != e.arg1 {
1172 return false
1173 }
1174 return true
1175 }
1176
1177 func (e *ExpectedGetAttachment) method(v bool) string {
1178 if !v {
1179 return "DB.GetAttachment()"
1180 }
1181 arg0, arg1, options := "?", "?", formatOptions(e.options)
1182 if e.arg0 != "" {
1183 arg0 = fmt.Sprintf("%q", e.arg0)
1184 }
1185 if e.arg1 != "" {
1186 arg1 = fmt.Sprintf("%q", e.arg1)
1187 }
1188 return fmt.Sprintf("DB(%s).GetAttachment(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
1189 }
1190
1191
1192 type ExpectedGetAttachmentMeta struct {
1193 commonExpectation
1194 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (*driver.Attachment, error)
1195 arg0 string
1196 arg1 string
1197 ret0 *driver.Attachment
1198 }
1199
1200
1201 func (e *ExpectedGetAttachmentMeta) WithOptions(options ...kivik.Option) *ExpectedGetAttachmentMeta {
1202 e.options = multiOptions{e.options, multiOptions(options)}
1203 return e
1204 }
1205
1206
1207
1208
1209 func (e *ExpectedGetAttachmentMeta) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (*driver.Attachment, error)) *ExpectedGetAttachmentMeta {
1210 e.callback = cb
1211 return e
1212 }
1213
1214
1215 func (e *ExpectedGetAttachmentMeta) WillReturn(ret0 *driver.Attachment) *ExpectedGetAttachmentMeta {
1216 e.ret0 = ret0
1217 return e
1218 }
1219
1220
1221 func (e *ExpectedGetAttachmentMeta) WillReturnError(err error) *ExpectedGetAttachmentMeta {
1222 e.err = err
1223 return e
1224 }
1225
1226
1227 func (e *ExpectedGetAttachmentMeta) WillDelay(delay time.Duration) *ExpectedGetAttachmentMeta {
1228 e.delay = delay
1229 return e
1230 }
1231
1232 func (e *ExpectedGetAttachmentMeta) met(ex expectation) bool {
1233 exp := ex.(*ExpectedGetAttachmentMeta)
1234 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1235 return false
1236 }
1237 if exp.arg1 != "" && exp.arg1 != e.arg1 {
1238 return false
1239 }
1240 return true
1241 }
1242
1243 func (e *ExpectedGetAttachmentMeta) method(v bool) string {
1244 if !v {
1245 return "DB.GetAttachmentMeta()"
1246 }
1247 arg0, arg1, options := "?", "?", formatOptions(e.options)
1248 if e.arg0 != "" {
1249 arg0 = fmt.Sprintf("%q", e.arg0)
1250 }
1251 if e.arg1 != "" {
1252 arg1 = fmt.Sprintf("%q", e.arg1)
1253 }
1254 return fmt.Sprintf("DB(%s).GetAttachmentMeta(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
1255 }
1256
1257
1258 type ExpectedGetIndexes struct {
1259 commonExpectation
1260 callback func(ctx context.Context, options driver.Options) ([]driver.Index, error)
1261 ret0 []driver.Index
1262 }
1263
1264
1265 func (e *ExpectedGetIndexes) WithOptions(options ...kivik.Option) *ExpectedGetIndexes {
1266 e.options = multiOptions{e.options, multiOptions(options)}
1267 return e
1268 }
1269
1270
1271
1272
1273 func (e *ExpectedGetIndexes) WillExecute(cb func(ctx context.Context, options driver.Options) ([]driver.Index, error)) *ExpectedGetIndexes {
1274 e.callback = cb
1275 return e
1276 }
1277
1278
1279 func (e *ExpectedGetIndexes) WillReturn(ret0 []driver.Index) *ExpectedGetIndexes {
1280 e.ret0 = ret0
1281 return e
1282 }
1283
1284
1285 func (e *ExpectedGetIndexes) WillReturnError(err error) *ExpectedGetIndexes {
1286 e.err = err
1287 return e
1288 }
1289
1290
1291 func (e *ExpectedGetIndexes) WillDelay(delay time.Duration) *ExpectedGetIndexes {
1292 e.delay = delay
1293 return e
1294 }
1295
1296 func (e *ExpectedGetIndexes) met(_ expectation) bool {
1297 return true
1298 }
1299
1300 func (e *ExpectedGetIndexes) method(v bool) string {
1301 if !v {
1302 return "DB.GetIndexes()"
1303 }
1304 options := formatOptions(e.options)
1305 return fmt.Sprintf("DB(%s).GetIndexes(ctx, %s)", e.dbo().name, options)
1306 }
1307
1308
1309 type ExpectedLocalDocs struct {
1310 commonExpectation
1311 callback func(ctx context.Context, options driver.Options) (driver.Rows, error)
1312 ret0 *Rows
1313 }
1314
1315
1316 func (e *ExpectedLocalDocs) WithOptions(options ...kivik.Option) *ExpectedLocalDocs {
1317 e.options = multiOptions{e.options, multiOptions(options)}
1318 return e
1319 }
1320
1321
1322
1323
1324 func (e *ExpectedLocalDocs) WillExecute(cb func(ctx context.Context, options driver.Options) (driver.Rows, error)) *ExpectedLocalDocs {
1325 e.callback = cb
1326 return e
1327 }
1328
1329
1330 func (e *ExpectedLocalDocs) WillReturn(ret0 *Rows) *ExpectedLocalDocs {
1331 e.ret0 = ret0
1332 return e
1333 }
1334
1335
1336 func (e *ExpectedLocalDocs) WillReturnError(err error) *ExpectedLocalDocs {
1337 e.err = err
1338 return e
1339 }
1340
1341
1342 func (e *ExpectedLocalDocs) WillDelay(delay time.Duration) *ExpectedLocalDocs {
1343 e.delay = delay
1344 return e
1345 }
1346
1347 func (e *ExpectedLocalDocs) met(_ expectation) bool {
1348 return true
1349 }
1350
1351 func (e *ExpectedLocalDocs) method(v bool) string {
1352 if !v {
1353 return "DB.LocalDocs()"
1354 }
1355 options := formatOptions(e.options)
1356 return fmt.Sprintf("DB(%s).LocalDocs(ctx, %s)", e.dbo().name, options)
1357 }
1358
1359
1360 type ExpectedOpenRevs struct {
1361 commonExpectation
1362 callback func(ctx context.Context, arg0 string, arg1 []string, options driver.Options) (driver.Rows, error)
1363 arg0 string
1364 arg1 []string
1365 ret0 *Rows
1366 }
1367
1368
1369 func (e *ExpectedOpenRevs) WithOptions(options ...kivik.Option) *ExpectedOpenRevs {
1370 e.options = multiOptions{e.options, multiOptions(options)}
1371 return e
1372 }
1373
1374
1375
1376
1377 func (e *ExpectedOpenRevs) WillExecute(cb func(ctx context.Context, arg0 string, arg1 []string, options driver.Options) (driver.Rows, error)) *ExpectedOpenRevs {
1378 e.callback = cb
1379 return e
1380 }
1381
1382
1383 func (e *ExpectedOpenRevs) WillReturn(ret0 *Rows) *ExpectedOpenRevs {
1384 e.ret0 = ret0
1385 return e
1386 }
1387
1388
1389 func (e *ExpectedOpenRevs) WillReturnError(err error) *ExpectedOpenRevs {
1390 e.err = err
1391 return e
1392 }
1393
1394
1395 func (e *ExpectedOpenRevs) WillDelay(delay time.Duration) *ExpectedOpenRevs {
1396 e.delay = delay
1397 return e
1398 }
1399
1400 func (e *ExpectedOpenRevs) met(ex expectation) bool {
1401 exp := ex.(*ExpectedOpenRevs)
1402 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1403 return false
1404 }
1405 if exp.arg1 != nil && !reflect.DeepEqual(exp.arg1, e.arg1) {
1406 return false
1407 }
1408 return true
1409 }
1410
1411 func (e *ExpectedOpenRevs) method(v bool) string {
1412 if !v {
1413 return "DB.OpenRevs()"
1414 }
1415 arg0, arg1, options := "?", "?", formatOptions(e.options)
1416 if e.arg0 != "" {
1417 arg0 = fmt.Sprintf("%q", e.arg0)
1418 }
1419 if e.arg1 != nil {
1420 arg1 = fmt.Sprintf("%v", e.arg1)
1421 }
1422 return fmt.Sprintf("DB(%s).OpenRevs(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
1423 }
1424
1425
1426 type ExpectedPartitionStats struct {
1427 commonExpectation
1428 callback func(ctx context.Context, arg0 string) (*driver.PartitionStats, error)
1429 arg0 string
1430 ret0 *driver.PartitionStats
1431 }
1432
1433
1434
1435
1436 func (e *ExpectedPartitionStats) WillExecute(cb func(ctx context.Context, arg0 string) (*driver.PartitionStats, error)) *ExpectedPartitionStats {
1437 e.callback = cb
1438 return e
1439 }
1440
1441
1442 func (e *ExpectedPartitionStats) WillReturn(ret0 *driver.PartitionStats) *ExpectedPartitionStats {
1443 e.ret0 = ret0
1444 return e
1445 }
1446
1447
1448 func (e *ExpectedPartitionStats) WillReturnError(err error) *ExpectedPartitionStats {
1449 e.err = err
1450 return e
1451 }
1452
1453
1454 func (e *ExpectedPartitionStats) WillDelay(delay time.Duration) *ExpectedPartitionStats {
1455 e.delay = delay
1456 return e
1457 }
1458
1459 func (e *ExpectedPartitionStats) met(ex expectation) bool {
1460 exp := ex.(*ExpectedPartitionStats)
1461 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1462 return false
1463 }
1464 return true
1465 }
1466
1467 func (e *ExpectedPartitionStats) method(v bool) string {
1468 if !v {
1469 return "DB.PartitionStats()"
1470 }
1471 arg0 := "?"
1472 if e.arg0 != "" {
1473 arg0 = fmt.Sprintf("%q", e.arg0)
1474 }
1475 return fmt.Sprintf("DB(%s).PartitionStats(ctx, %s)", e.dbo().name, arg0)
1476 }
1477
1478
1479 type ExpectedPurge struct {
1480 commonExpectation
1481 callback func(ctx context.Context, arg0 map[string][]string) (*driver.PurgeResult, error)
1482 arg0 map[string][]string
1483 ret0 *driver.PurgeResult
1484 }
1485
1486
1487
1488
1489 func (e *ExpectedPurge) WillExecute(cb func(ctx context.Context, arg0 map[string][]string) (*driver.PurgeResult, error)) *ExpectedPurge {
1490 e.callback = cb
1491 return e
1492 }
1493
1494
1495 func (e *ExpectedPurge) WillReturn(ret0 *driver.PurgeResult) *ExpectedPurge {
1496 e.ret0 = ret0
1497 return e
1498 }
1499
1500
1501 func (e *ExpectedPurge) WillReturnError(err error) *ExpectedPurge {
1502 e.err = err
1503 return e
1504 }
1505
1506
1507 func (e *ExpectedPurge) WillDelay(delay time.Duration) *ExpectedPurge {
1508 e.delay = delay
1509 return e
1510 }
1511
1512 func (e *ExpectedPurge) met(ex expectation) bool {
1513 exp := ex.(*ExpectedPurge)
1514 if exp.arg0 != nil && !reflect.DeepEqual(exp.arg0, e.arg0) {
1515 return false
1516 }
1517 return true
1518 }
1519
1520 func (e *ExpectedPurge) method(v bool) string {
1521 if !v {
1522 return "DB.Purge()"
1523 }
1524 arg0 := "?"
1525 if e.arg0 != nil {
1526 arg0 = fmt.Sprintf("%v", e.arg0)
1527 }
1528 return fmt.Sprintf("DB(%s).Purge(ctx, %s)", e.dbo().name, arg0)
1529 }
1530
1531
1532 type ExpectedPutAttachment struct {
1533 commonExpectation
1534 callback func(ctx context.Context, arg0 string, arg1 *driver.Attachment, options driver.Options) (string, error)
1535 arg0 string
1536 arg1 *driver.Attachment
1537 ret0 string
1538 }
1539
1540
1541 func (e *ExpectedPutAttachment) WithOptions(options ...kivik.Option) *ExpectedPutAttachment {
1542 e.options = multiOptions{e.options, multiOptions(options)}
1543 return e
1544 }
1545
1546
1547
1548
1549 func (e *ExpectedPutAttachment) WillExecute(cb func(ctx context.Context, arg0 string, arg1 *driver.Attachment, options driver.Options) (string, error)) *ExpectedPutAttachment {
1550 e.callback = cb
1551 return e
1552 }
1553
1554
1555 func (e *ExpectedPutAttachment) WillReturn(ret0 string) *ExpectedPutAttachment {
1556 e.ret0 = ret0
1557 return e
1558 }
1559
1560
1561 func (e *ExpectedPutAttachment) WillReturnError(err error) *ExpectedPutAttachment {
1562 e.err = err
1563 return e
1564 }
1565
1566
1567 func (e *ExpectedPutAttachment) WillDelay(delay time.Duration) *ExpectedPutAttachment {
1568 e.delay = delay
1569 return e
1570 }
1571
1572 func (e *ExpectedPutAttachment) met(ex expectation) bool {
1573 exp := ex.(*ExpectedPutAttachment)
1574 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1575 return false
1576 }
1577 if exp.arg1 != nil && !reflect.DeepEqual(exp.arg1, e.arg1) {
1578 return false
1579 }
1580 return true
1581 }
1582
1583 func (e *ExpectedPutAttachment) method(v bool) string {
1584 if !v {
1585 return "DB.PutAttachment()"
1586 }
1587 arg0, arg1, options := "?", "?", formatOptions(e.options)
1588 if e.arg0 != "" {
1589 arg0 = fmt.Sprintf("%q", e.arg0)
1590 }
1591 if e.arg1 != nil {
1592 arg1 = fmt.Sprintf("%v", e.arg1)
1593 }
1594 return fmt.Sprintf("DB(%s).PutAttachment(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
1595 }
1596
1597
1598 type ExpectedQuery struct {
1599 commonExpectation
1600 callback func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (driver.Rows, error)
1601 arg0 string
1602 arg1 string
1603 ret0 *Rows
1604 }
1605
1606
1607 func (e *ExpectedQuery) WithOptions(options ...kivik.Option) *ExpectedQuery {
1608 e.options = multiOptions{e.options, multiOptions(options)}
1609 return e
1610 }
1611
1612
1613
1614
1615 func (e *ExpectedQuery) WillExecute(cb func(ctx context.Context, arg0 string, arg1 string, options driver.Options) (driver.Rows, error)) *ExpectedQuery {
1616 e.callback = cb
1617 return e
1618 }
1619
1620
1621 func (e *ExpectedQuery) WillReturn(ret0 *Rows) *ExpectedQuery {
1622 e.ret0 = ret0
1623 return e
1624 }
1625
1626
1627 func (e *ExpectedQuery) WillReturnError(err error) *ExpectedQuery {
1628 e.err = err
1629 return e
1630 }
1631
1632
1633 func (e *ExpectedQuery) WillDelay(delay time.Duration) *ExpectedQuery {
1634 e.delay = delay
1635 return e
1636 }
1637
1638 func (e *ExpectedQuery) met(ex expectation) bool {
1639 exp := ex.(*ExpectedQuery)
1640 if exp.arg0 != "" && exp.arg0 != e.arg0 {
1641 return false
1642 }
1643 if exp.arg1 != "" && exp.arg1 != e.arg1 {
1644 return false
1645 }
1646 return true
1647 }
1648
1649 func (e *ExpectedQuery) method(v bool) string {
1650 if !v {
1651 return "DB.Query()"
1652 }
1653 arg0, arg1, options := "?", "?", formatOptions(e.options)
1654 if e.arg0 != "" {
1655 arg0 = fmt.Sprintf("%q", e.arg0)
1656 }
1657 if e.arg1 != "" {
1658 arg1 = fmt.Sprintf("%q", e.arg1)
1659 }
1660 return fmt.Sprintf("DB(%s).Query(ctx, %s, %s, %s)", e.dbo().name, arg0, arg1, options)
1661 }
1662
1663
1664 type ExpectedRevsDiff struct {
1665 commonExpectation
1666 callback func(ctx context.Context, arg0 interface{}) (driver.Rows, error)
1667 arg0 interface{}
1668 ret0 *Rows
1669 }
1670
1671
1672
1673
1674 func (e *ExpectedRevsDiff) WillExecute(cb func(ctx context.Context, arg0 interface{}) (driver.Rows, error)) *ExpectedRevsDiff {
1675 e.callback = cb
1676 return e
1677 }
1678
1679
1680 func (e *ExpectedRevsDiff) WillReturn(ret0 *Rows) *ExpectedRevsDiff {
1681 e.ret0 = ret0
1682 return e
1683 }
1684
1685
1686 func (e *ExpectedRevsDiff) WillReturnError(err error) *ExpectedRevsDiff {
1687 e.err = err
1688 return e
1689 }
1690
1691
1692 func (e *ExpectedRevsDiff) WillDelay(delay time.Duration) *ExpectedRevsDiff {
1693 e.delay = delay
1694 return e
1695 }
1696
1697 func (e *ExpectedRevsDiff) met(ex expectation) bool {
1698 exp := ex.(*ExpectedRevsDiff)
1699 if exp.arg0 != nil && !jsonMeets(exp.arg0, e.arg0) {
1700 return false
1701 }
1702 return true
1703 }
1704
1705 func (e *ExpectedRevsDiff) method(v bool) string {
1706 if !v {
1707 return "DB.RevsDiff()"
1708 }
1709 arg0 := "?"
1710 if e.arg0 != nil {
1711 arg0 = fmt.Sprintf("%v", e.arg0)
1712 }
1713 return fmt.Sprintf("DB(%s).RevsDiff(ctx, %s)", e.dbo().name, arg0)
1714 }
1715
1716
1717 type ExpectedSecurity struct {
1718 commonExpectation
1719 callback func(ctx context.Context) (*driver.Security, error)
1720 ret0 *driver.Security
1721 }
1722
1723
1724
1725
1726 func (e *ExpectedSecurity) WillExecute(cb func(ctx context.Context) (*driver.Security, error)) *ExpectedSecurity {
1727 e.callback = cb
1728 return e
1729 }
1730
1731
1732 func (e *ExpectedSecurity) WillReturn(ret0 *driver.Security) *ExpectedSecurity {
1733 e.ret0 = ret0
1734 return e
1735 }
1736
1737
1738 func (e *ExpectedSecurity) WillReturnError(err error) *ExpectedSecurity {
1739 e.err = err
1740 return e
1741 }
1742
1743
1744 func (e *ExpectedSecurity) WillDelay(delay time.Duration) *ExpectedSecurity {
1745 e.delay = delay
1746 return e
1747 }
1748
1749 func (e *ExpectedSecurity) met(_ expectation) bool {
1750 return true
1751 }
1752
1753 func (e *ExpectedSecurity) method(v bool) string {
1754 if !v {
1755 return "DB.Security()"
1756 }
1757 return fmt.Sprintf("DB(%s).Security(ctx)", e.dbo().name)
1758 }
1759
1760
1761 type ExpectedSetSecurity struct {
1762 commonExpectation
1763 callback func(ctx context.Context, arg0 *driver.Security) error
1764 arg0 *driver.Security
1765 }
1766
1767
1768
1769
1770 func (e *ExpectedSetSecurity) WillExecute(cb func(ctx context.Context, arg0 *driver.Security) error) *ExpectedSetSecurity {
1771 e.callback = cb
1772 return e
1773 }
1774
1775
1776 func (e *ExpectedSetSecurity) WillReturnError(err error) *ExpectedSetSecurity {
1777 e.err = err
1778 return e
1779 }
1780
1781
1782 func (e *ExpectedSetSecurity) WillDelay(delay time.Duration) *ExpectedSetSecurity {
1783 e.delay = delay
1784 return e
1785 }
1786
1787 func (e *ExpectedSetSecurity) met(ex expectation) bool {
1788 exp := ex.(*ExpectedSetSecurity)
1789 if exp.arg0 != nil && !reflect.DeepEqual(exp.arg0, e.arg0) {
1790 return false
1791 }
1792 return true
1793 }
1794
1795 func (e *ExpectedSetSecurity) method(v bool) string {
1796 if !v {
1797 return "DB.SetSecurity()"
1798 }
1799 arg0 := "?"
1800 if e.arg0 != nil {
1801 arg0 = fmt.Sprintf("%v", e.arg0)
1802 }
1803 return fmt.Sprintf("DB(%s).SetSecurity(ctx, %s)", e.dbo().name, arg0)
1804 }
1805
1806
1807 type ExpectedStats struct {
1808 commonExpectation
1809 callback func(ctx context.Context) (*driver.DBStats, error)
1810 ret0 *driver.DBStats
1811 }
1812
1813
1814
1815
1816 func (e *ExpectedStats) WillExecute(cb func(ctx context.Context) (*driver.DBStats, error)) *ExpectedStats {
1817 e.callback = cb
1818 return e
1819 }
1820
1821
1822 func (e *ExpectedStats) WillReturn(ret0 *driver.DBStats) *ExpectedStats {
1823 e.ret0 = ret0
1824 return e
1825 }
1826
1827
1828 func (e *ExpectedStats) WillReturnError(err error) *ExpectedStats {
1829 e.err = err
1830 return e
1831 }
1832
1833
1834 func (e *ExpectedStats) WillDelay(delay time.Duration) *ExpectedStats {
1835 e.delay = delay
1836 return e
1837 }
1838
1839 func (e *ExpectedStats) met(_ expectation) bool {
1840 return true
1841 }
1842
1843 func (e *ExpectedStats) method(v bool) string {
1844 if !v {
1845 return "DB.Stats()"
1846 }
1847 return fmt.Sprintf("DB(%s).Stats(ctx)", e.dbo().name)
1848 }
1849
View as plain text