1
2
3
4
5
6
7 package require
8
9 import (
10 time "time"
11
12 assert "go.mongodb.org/mongo-driver/internal/assert"
13 )
14
15
16 type TestingT interface {
17 Errorf(format string, args ...interface{})
18 FailNow()
19 }
20
21 type tHelper interface {
22 Helper()
23 }
24
25
26
27
28
29
30
31 func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
32 if h, ok := t.(tHelper); ok {
33 h.Helper()
34 }
35 if assert.Contains(t, s, contains, msgAndArgs...) {
36 return
37 }
38 t.FailNow()
39 }
40
41
42
43
44
45
46
47 func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
48 if h, ok := t.(tHelper); ok {
49 h.Helper()
50 }
51 if assert.Containsf(t, s, contains, msg, args...) {
52 return
53 }
54 t.FailNow()
55 }
56
57
58
59
60
61
62 func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) {
63 if h, ok := t.(tHelper); ok {
64 h.Helper()
65 }
66 if assert.ElementsMatch(t, listA, listB, msgAndArgs...) {
67 return
68 }
69 t.FailNow()
70 }
71
72
73
74
75
76
77 func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) {
78 if h, ok := t.(tHelper); ok {
79 h.Helper()
80 }
81 if assert.ElementsMatchf(t, listA, listB, msg, args...) {
82 return
83 }
84 t.FailNow()
85 }
86
87
88
89
90
91
92
93
94 func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
95 if h, ok := t.(tHelper); ok {
96 h.Helper()
97 }
98 if assert.Equal(t, expected, actual, msgAndArgs...) {
99 return
100 }
101 t.FailNow()
102 }
103
104
105
106
107
108
109 func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
110 if h, ok := t.(tHelper); ok {
111 h.Helper()
112 }
113 if assert.EqualError(t, theError, errString, msgAndArgs...) {
114 return
115 }
116 t.FailNow()
117 }
118
119
120
121
122
123
124 func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
125 if h, ok := t.(tHelper); ok {
126 h.Helper()
127 }
128 if assert.EqualErrorf(t, theError, errString, msg, args...) {
129 return
130 }
131 t.FailNow()
132 }
133
134
135
136
137
138 func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
139 if h, ok := t.(tHelper); ok {
140 h.Helper()
141 }
142 if assert.EqualValues(t, expected, actual, msgAndArgs...) {
143 return
144 }
145 t.FailNow()
146 }
147
148
149
150
151
152 func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
153 if h, ok := t.(tHelper); ok {
154 h.Helper()
155 }
156 if assert.EqualValuesf(t, expected, actual, msg, args...) {
157 return
158 }
159 t.FailNow()
160 }
161
162
163
164
165
166
167
168
169 func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
170 if h, ok := t.(tHelper); ok {
171 h.Helper()
172 }
173 if assert.Equalf(t, expected, actual, msg, args...) {
174 return
175 }
176 t.FailNow()
177 }
178
179
180
181
182
183
184
185 func Error(t TestingT, err error, msgAndArgs ...interface{}) {
186 if h, ok := t.(tHelper); ok {
187 h.Helper()
188 }
189 if assert.Error(t, err, msgAndArgs...) {
190 return
191 }
192 t.FailNow()
193 }
194
195
196
197
198
199
200 func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) {
201 if h, ok := t.(tHelper); ok {
202 h.Helper()
203 }
204 if assert.ErrorContains(t, theError, contains, msgAndArgs...) {
205 return
206 }
207 t.FailNow()
208 }
209
210
211
212
213
214
215 func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) {
216 if h, ok := t.(tHelper); ok {
217 h.Helper()
218 }
219 if assert.ErrorContainsf(t, theError, contains, msg, args...) {
220 return
221 }
222 t.FailNow()
223 }
224
225
226
227
228
229
230
231 func Errorf(t TestingT, err error, msg string, args ...interface{}) {
232 if h, ok := t.(tHelper); ok {
233 h.Helper()
234 }
235 if assert.Errorf(t, err, msg, args...) {
236 return
237 }
238 t.FailNow()
239 }
240
241
242
243
244
245 func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
246 if h, ok := t.(tHelper); ok {
247 h.Helper()
248 }
249 if assert.Eventually(t, condition, waitFor, tick, msgAndArgs...) {
250 return
251 }
252 t.FailNow()
253 }
254
255
256
257
258
259 func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
260 if h, ok := t.(tHelper); ok {
261 h.Helper()
262 }
263 if assert.Eventuallyf(t, condition, waitFor, tick, msg, args...) {
264 return
265 }
266 t.FailNow()
267 }
268
269
270 func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
271 if h, ok := t.(tHelper); ok {
272 h.Helper()
273 }
274 if assert.Fail(t, failureMessage, msgAndArgs...) {
275 return
276 }
277 t.FailNow()
278 }
279
280
281 func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
282 if h, ok := t.(tHelper); ok {
283 h.Helper()
284 }
285 if assert.FailNow(t, failureMessage, msgAndArgs...) {
286 return
287 }
288 t.FailNow()
289 }
290
291
292 func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
293 if h, ok := t.(tHelper); ok {
294 h.Helper()
295 }
296 if assert.FailNowf(t, failureMessage, msg, args...) {
297 return
298 }
299 t.FailNow()
300 }
301
302
303 func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
304 if h, ok := t.(tHelper); ok {
305 h.Helper()
306 }
307 if assert.Failf(t, failureMessage, msg, args...) {
308 return
309 }
310 t.FailNow()
311 }
312
313
314
315
316 func False(t TestingT, value bool, msgAndArgs ...interface{}) {
317 if h, ok := t.(tHelper); ok {
318 h.Helper()
319 }
320 if assert.False(t, value, msgAndArgs...) {
321 return
322 }
323 t.FailNow()
324 }
325
326
327
328
329 func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
330 if h, ok := t.(tHelper); ok {
331 h.Helper()
332 }
333 if assert.Falsef(t, value, msg, args...) {
334 return
335 }
336 t.FailNow()
337 }
338
339
340
341
342
343
344 func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
345 if h, ok := t.(tHelper); ok {
346 h.Helper()
347 }
348 if assert.Greater(t, e1, e2, msgAndArgs...) {
349 return
350 }
351 t.FailNow()
352 }
353
354
355
356
357
358
359
360 func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
361 if h, ok := t.(tHelper); ok {
362 h.Helper()
363 }
364 if assert.GreaterOrEqual(t, e1, e2, msgAndArgs...) {
365 return
366 }
367 t.FailNow()
368 }
369
370
371
372
373
374
375
376 func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
377 if h, ok := t.(tHelper); ok {
378 h.Helper()
379 }
380 if assert.GreaterOrEqualf(t, e1, e2, msg, args...) {
381 return
382 }
383 t.FailNow()
384 }
385
386
387
388
389
390
391 func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
392 if h, ok := t.(tHelper); ok {
393 h.Helper()
394 }
395 if assert.Greaterf(t, e1, e2, msg, args...) {
396 return
397 }
398 t.FailNow()
399 }
400
401
402
403
404 func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
405 if h, ok := t.(tHelper); ok {
406 h.Helper()
407 }
408 if assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
409 return
410 }
411 t.FailNow()
412 }
413
414
415
416
417 func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
418 if h, ok := t.(tHelper); ok {
419 h.Helper()
420 }
421 if assert.InDeltaf(t, expected, actual, delta, msg, args...) {
422 return
423 }
424 t.FailNow()
425 }
426
427
428 func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
429 if h, ok := t.(tHelper); ok {
430 h.Helper()
431 }
432 if assert.IsType(t, expectedType, object, msgAndArgs...) {
433 return
434 }
435 t.FailNow()
436 }
437
438
439 func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
440 if h, ok := t.(tHelper); ok {
441 h.Helper()
442 }
443 if assert.IsTypef(t, expectedType, object, msg, args...) {
444 return
445 }
446 t.FailNow()
447 }
448
449
450
451
452
453 func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
454 if h, ok := t.(tHelper); ok {
455 h.Helper()
456 }
457 if assert.Len(t, object, length, msgAndArgs...) {
458 return
459 }
460 t.FailNow()
461 }
462
463
464
465
466
467 func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
468 if h, ok := t.(tHelper); ok {
469 h.Helper()
470 }
471 if assert.Lenf(t, object, length, msg, args...) {
472 return
473 }
474 t.FailNow()
475 }
476
477
478
479
480
481
482 func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
483 if h, ok := t.(tHelper); ok {
484 h.Helper()
485 }
486 if assert.Less(t, e1, e2, msgAndArgs...) {
487 return
488 }
489 t.FailNow()
490 }
491
492
493
494
495
496
497
498 func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) {
499 if h, ok := t.(tHelper); ok {
500 h.Helper()
501 }
502 if assert.LessOrEqual(t, e1, e2, msgAndArgs...) {
503 return
504 }
505 t.FailNow()
506 }
507
508
509
510
511
512
513
514 func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
515 if h, ok := t.(tHelper); ok {
516 h.Helper()
517 }
518 if assert.LessOrEqualf(t, e1, e2, msg, args...) {
519 return
520 }
521 t.FailNow()
522 }
523
524
525
526
527
528
529 func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) {
530 if h, ok := t.(tHelper); ok {
531 h.Helper()
532 }
533 if assert.Lessf(t, e1, e2, msg, args...) {
534 return
535 }
536 t.FailNow()
537 }
538
539
540
541
542
543 func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
544 if h, ok := t.(tHelper); ok {
545 h.Helper()
546 }
547 if assert.Negative(t, e, msgAndArgs...) {
548 return
549 }
550 t.FailNow()
551 }
552
553
554
555
556
557 func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) {
558 if h, ok := t.(tHelper); ok {
559 h.Helper()
560 }
561 if assert.Negativef(t, e, msg, args...) {
562 return
563 }
564 t.FailNow()
565 }
566
567
568
569
570 func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
571 if h, ok := t.(tHelper); ok {
572 h.Helper()
573 }
574 if assert.Nil(t, object, msgAndArgs...) {
575 return
576 }
577 t.FailNow()
578 }
579
580
581
582
583 func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
584 if h, ok := t.(tHelper); ok {
585 h.Helper()
586 }
587 if assert.Nilf(t, object, msg, args...) {
588 return
589 }
590 t.FailNow()
591 }
592
593
594
595
596
597
598
599 func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
600 if h, ok := t.(tHelper); ok {
601 h.Helper()
602 }
603 if assert.NoError(t, err, msgAndArgs...) {
604 return
605 }
606 t.FailNow()
607 }
608
609
610
611
612
613
614
615 func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
616 if h, ok := t.(tHelper); ok {
617 h.Helper()
618 }
619 if assert.NoErrorf(t, err, msg, args...) {
620 return
621 }
622 t.FailNow()
623 }
624
625
626
627
628
629
630
631 func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
632 if h, ok := t.(tHelper); ok {
633 h.Helper()
634 }
635 if assert.NotContains(t, s, contains, msgAndArgs...) {
636 return
637 }
638 t.FailNow()
639 }
640
641
642
643
644
645
646
647 func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
648 if h, ok := t.(tHelper); ok {
649 h.Helper()
650 }
651 if assert.NotContainsf(t, s, contains, msg, args...) {
652 return
653 }
654 t.FailNow()
655 }
656
657
658
659
660
661
662
663 func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
664 if h, ok := t.(tHelper); ok {
665 h.Helper()
666 }
667 if assert.NotEqual(t, expected, actual, msgAndArgs...) {
668 return
669 }
670 t.FailNow()
671 }
672
673
674
675
676 func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
677 if h, ok := t.(tHelper); ok {
678 h.Helper()
679 }
680 if assert.NotEqualValues(t, expected, actual, msgAndArgs...) {
681 return
682 }
683 t.FailNow()
684 }
685
686
687
688
689 func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
690 if h, ok := t.(tHelper); ok {
691 h.Helper()
692 }
693 if assert.NotEqualValuesf(t, expected, actual, msg, args...) {
694 return
695 }
696 t.FailNow()
697 }
698
699
700
701
702
703
704
705 func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
706 if h, ok := t.(tHelper); ok {
707 h.Helper()
708 }
709 if assert.NotEqualf(t, expected, actual, msg, args...) {
710 return
711 }
712 t.FailNow()
713 }
714
715
716
717
718 func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
719 if h, ok := t.(tHelper); ok {
720 h.Helper()
721 }
722 if assert.NotNil(t, object, msgAndArgs...) {
723 return
724 }
725 t.FailNow()
726 }
727
728
729
730
731 func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
732 if h, ok := t.(tHelper); ok {
733 h.Helper()
734 }
735 if assert.NotNilf(t, object, msg, args...) {
736 return
737 }
738 t.FailNow()
739 }
740
741
742
743
744
745 func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
746 if h, ok := t.(tHelper); ok {
747 h.Helper()
748 }
749 if assert.Positive(t, e, msgAndArgs...) {
750 return
751 }
752 t.FailNow()
753 }
754
755
756
757
758
759 func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) {
760 if h, ok := t.(tHelper); ok {
761 h.Helper()
762 }
763 if assert.Positivef(t, e, msg, args...) {
764 return
765 }
766 t.FailNow()
767 }
768
769
770
771
772 func True(t TestingT, value bool, msgAndArgs ...interface{}) {
773 if h, ok := t.(tHelper); ok {
774 h.Helper()
775 }
776 if assert.True(t, value, msgAndArgs...) {
777 return
778 }
779 t.FailNow()
780 }
781
782
783
784
785 func Truef(t TestingT, value bool, msg string, args ...interface{}) {
786 if h, ok := t.(tHelper); ok {
787 h.Helper()
788 }
789 if assert.Truef(t, value, msg, args...) {
790 return
791 }
792 t.FailNow()
793 }
794
795
796
797
798 func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
799 if h, ok := t.(tHelper); ok {
800 h.Helper()
801 }
802 if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
803 return
804 }
805 t.FailNow()
806 }
807
808
809
810
811 func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
812 if h, ok := t.(tHelper); ok {
813 h.Helper()
814 }
815 if assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
816 return
817 }
818 t.FailNow()
819 }
820
View as plain text