@@ -382,6 +382,9 @@ type assertExpectationser interface {
382
382
//
383
383
// Calls may have occurred in any order.
384
384
func AssertExpectationsForObjects (t TestingT , testObjects ... interface {}) bool {
385
+ if h , ok := t .(tHelper ); ok {
386
+ h .Helper ()
387
+ }
385
388
for _ , obj := range testObjects {
386
389
if m , ok := obj .(Mock ); ok {
387
390
t .Logf ("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)" )
@@ -399,6 +402,9 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
399
402
// AssertExpectations asserts that everything specified with On and Return was
400
403
// in fact called as expected. Calls may have occurred in any order.
401
404
func (m * Mock ) AssertExpectations (t TestingT ) bool {
405
+ if h , ok := t .(tHelper ); ok {
406
+ h .Helper ()
407
+ }
402
408
m .mutex .Lock ()
403
409
defer m .mutex .Unlock ()
404
410
var somethingMissing bool
@@ -431,6 +437,9 @@ func (m *Mock) AssertExpectations(t TestingT) bool {
431
437
432
438
// AssertNumberOfCalls asserts that the method was called expectedCalls times.
433
439
func (m * Mock ) AssertNumberOfCalls (t TestingT , methodName string , expectedCalls int ) bool {
440
+ if h , ok := t .(tHelper ); ok {
441
+ h .Helper ()
442
+ }
434
443
m .mutex .Lock ()
435
444
defer m .mutex .Unlock ()
436
445
var actualCalls int
@@ -445,6 +454,9 @@ func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls
445
454
// AssertCalled asserts that the method was called.
446
455
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
447
456
func (m * Mock ) AssertCalled (t TestingT , methodName string , arguments ... interface {}) bool {
457
+ if h , ok := t .(tHelper ); ok {
458
+ h .Helper ()
459
+ }
448
460
m .mutex .Lock ()
449
461
defer m .mutex .Unlock ()
450
462
if ! m .methodWasCalled (methodName , arguments ) {
@@ -465,6 +477,9 @@ func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interfac
465
477
// AssertNotCalled asserts that the method was not called.
466
478
// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method.
467
479
func (m * Mock ) AssertNotCalled (t TestingT , methodName string , arguments ... interface {}) bool {
480
+ if h , ok := t .(tHelper ); ok {
481
+ h .Helper ()
482
+ }
468
483
m .mutex .Lock ()
469
484
defer m .mutex .Unlock ()
470
485
if m .methodWasCalled (methodName , arguments ) {
@@ -679,6 +694,9 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {
679
694
// Assert compares the arguments with the specified objects and fails if
680
695
// they do not exactly match.
681
696
func (args Arguments ) Assert (t TestingT , objects ... interface {}) bool {
697
+ if h , ok := t .(tHelper ); ok {
698
+ h .Helper ()
699
+ }
682
700
683
701
// get the differences
684
702
diff , diffCount := args .Diff (objects )
@@ -826,3 +844,7 @@ var spewConfig = spew.ConfigState{
826
844
DisableCapacities : true ,
827
845
SortKeys : true ,
828
846
}
847
+
848
+ type tHelper interface {
849
+ Helper ()
850
+ }
0 commit comments