From 9c174eb41c6bd1d44d9aec62f68b8f1c514f3f5f Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Tue, 23 Jul 2024 16:18:22 +0200 Subject: [PATCH 1/9] fix: compare functional option names for indirect calls Closes Functional Options testing broken for indirect calls #1380 --- mock/mock.go | 9 ++++++++- mock/mock_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mock/mock.go b/mock/mock.go index 49328337b..009767554 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1260,5 +1260,12 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { func funcName(opt interface{}) string { n := runtime.FuncForPC(reflect.ValueOf(opt).Pointer()).Name() - return strings.TrimSuffix(path.Base(n), path.Ext(n)) + trimmed := strings.TrimSuffix(path.Base(n), path.Ext(n)) + splitted := strings.Split(trimmed, ".") + + if len(splitted) == 0 { + return trimmed + } + + return splitted[len(splitted)-1] } diff --git a/mock/mock_test.go b/mock/mock_test.go index d28686700..12fb45e74 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -55,6 +55,10 @@ func (i *TestExampleImplementation) TheExampleMethodFunctionalOptions(x string, return args.Error(0) } +func TheExampleMethodFunctionalOptionsIndirect(i *TestExampleImplementation) { + i.TheExampleMethodFunctionalOptions("test", OpNum(1), OpStr("foo")) +} + //go:noinline func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) { i.Called(yesorno) @@ -1505,6 +1509,23 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType(t *testing.T) { } +func Test_Mock_AssertExpectationsFunctionalOptionsTypeIndirectly(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpNum(1), OpStr("foo"))).Return(nil).Once() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + TheExampleMethodFunctionalOptionsIndirect(mockedService) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing.T) { var mockedService = new(TestExampleImplementation) @@ -1522,6 +1543,20 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing.T) { } +func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpNum(1))).Return(nil).Once() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + assert.Panics(t, func() { + mockedService.TheExampleMethodFunctionalOptions("test", OpStr("1")) + }) +} + func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) { var mockedService = new(TestExampleImplementation) From 22d3bd5defb6f5dfe50062c22651669393ecdbc5 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Tue, 23 Jul 2024 16:53:06 +0200 Subject: [PATCH 2/9] in order to remain compatible with go1..19, don't compare function names (but do include them in the diff output) --- mock/mock.go | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 009767554..19ec01d87 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1204,17 +1204,10 @@ type tHelper interface { func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpts := reflect.ValueOf(expected) actualOpts := reflect.ValueOf(actual) - var expectedNames []string - for i := 0; i < expectedOpts.Len(); i++ { - expectedNames = append(expectedNames, funcName(expectedOpts.Index(i).Interface())) - } - var actualNames []string - for i := 0; i < actualOpts.Len(); i++ { - actualNames = append(actualNames, funcName(actualOpts.Index(i).Interface())) - } - if !assert.ObjectsAreEqual(expectedNames, actualNames) { - expectedFmt = fmt.Sprintf("%v", expectedNames) - actualFmt = fmt.Sprintf("%v", actualNames) + + if expectedOpts.Len() != actualOpts.Len() { + expectedFmt = fmt.Sprintf("%v", expectedOpts) + actualFmt = fmt.Sprintf("%v", actualOpts) return } @@ -1222,14 +1215,6 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpt := expectedOpts.Index(i).Interface() actualOpt := actualOpts.Index(i).Interface() - expectedFunc := expectedNames[i] - actualFunc := actualNames[i] - if expectedFunc != actualFunc { - expectedFmt = expectedFunc - actualFmt = actualFunc - return - } - ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value var actualValues []reflect.Value @@ -1248,8 +1233,8 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { for i := 0; i < ot.NumIn(); i++ { if !assert.ObjectsAreEqual(expectedValues[i].Interface(), actualValues[i].Interface()) { - expectedFmt = fmt.Sprintf("%s %+v", expectedNames[i], expectedValues[i].Interface()) - actualFmt = fmt.Sprintf("%s %+v", expectedNames[i], actualValues[i].Interface()) + expectedFmt = fmt.Sprintf("%s %+v", funcName(expectedOpts.Index(i).Interface()), expectedValues[i].Interface()) + actualFmt = fmt.Sprintf("%s %+v", funcName(actualOpts.Index(i).Interface()), actualValues[i].Interface()) return } } From 822223ec3418f3f55230d59b2701b9d6dafff758 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Tue, 22 Oct 2024 16:04:49 +0200 Subject: [PATCH 3/9] fix name regression --- mock/mock.go | 20 +++++++++++++++++--- mock/mock_test.go | 29 +++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 19ec01d87..487dca2b3 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1211,6 +1211,20 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { return } + var expectedNames []string + for i := 0; i < expectedOpts.Len(); i++ { + expectedNames = append(expectedNames, funcName(expectedOpts.Index(i).Interface())) + } + var actualNames []string + for i := 0; i < actualOpts.Len(); i++ { + actualNames = append(actualNames, funcName(actualOpts.Index(i).Interface())) + } + if !assert.ObjectsAreEqual(expectedNames, actualNames) { + expectedFmt = fmt.Sprintf("%v", expectedNames) + actualFmt = fmt.Sprintf("%v", actualNames) + return + } + for i := 0; i < expectedOpts.Len(); i++ { expectedOpt := expectedOpts.Index(i).Interface() actualOpt := actualOpts.Index(i).Interface() @@ -1232,9 +1246,9 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { reflect.ValueOf(actualOpt).Call(actualValues) for i := 0; i < ot.NumIn(); i++ { - if !assert.ObjectsAreEqual(expectedValues[i].Interface(), actualValues[i].Interface()) { - expectedFmt = fmt.Sprintf("%s %+v", funcName(expectedOpts.Index(i).Interface()), expectedValues[i].Interface()) - actualFmt = fmt.Sprintf("%s %+v", funcName(actualOpts.Index(i).Interface()), actualValues[i].Interface()) + if expectedArg, actualArg := expectedValues[i].Interface(), actualValues[i].Interface(); !assert.ObjectsAreEqual(expectedArg, actualArg) { + expectedFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], expectedArg, expectedArg) + actualFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], actualArg, actualArg) return } } diff --git a/mock/mock_test.go b/mock/mock_test.go index 12fb45e74..e5bdaef9d 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -50,6 +50,13 @@ func OpStr(s string) OptionFn { o.str = s } } + +func OpBytes(b []byte) OptionFn { + return func(m *options) { + m.str = string(b) + } +} + func (i *TestExampleImplementation) TheExampleMethodFunctionalOptions(x string, opts ...OptionFn) error { args := i.Called(x, opts) return args.Error(0) @@ -1509,7 +1516,7 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType(t *testing.T) { } -func Test_Mock_AssertExpectationsFunctionalOptionsTypeIndirectly(t *testing.T) { +func Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly(t *testing.T) { var mockedService = new(TestExampleImplementation) @@ -1543,17 +1550,31 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing.T) { } -func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff(t *testing.T) { +func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Name(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpStr("this"))).Return(nil).Once() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + assert.Panics(t, func() { + mockedService.TheExampleMethodFunctionalOptions("test", OpBytes([]byte("this"))) + }) +} + +func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Arg(t *testing.T) { var mockedService = new(TestExampleImplementation) - mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpNum(1))).Return(nil).Once() + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpStr("this"))).Return(nil).Once() tt := new(testing.T) assert.False(t, mockedService.AssertExpectations(tt)) assert.Panics(t, func() { - mockedService.TheExampleMethodFunctionalOptions("test", OpStr("1")) + mockedService.TheExampleMethodFunctionalOptions("test", OpStr("that")) }) } From 55bac843547859145b0a174024ce495256cff5f8 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Thu, 24 Oct 2024 11:28:15 +0200 Subject: [PATCH 4/9] reword tests --- mock/mock_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mock/mock_test.go b/mock/mock_test.go index e5bdaef9d..71249239b 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -1516,34 +1516,34 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType(t *testing.T) { } -func Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly(t *testing.T) { +func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing.T) { var mockedService = new(TestExampleImplementation) - mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpNum(1), OpStr("foo"))).Return(nil).Once() + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions()).Return(nil).Once() tt := new(testing.T) assert.False(t, mockedService.AssertExpectations(tt)) // make the call now - TheExampleMethodFunctionalOptionsIndirect(mockedService) + mockedService.TheExampleMethodFunctionalOptions("test") // now assert expectations assert.True(t, mockedService.AssertExpectations(tt)) } -func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing.T) { +func Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly(t *testing.T) { var mockedService = new(TestExampleImplementation) - mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions()).Return(nil).Once() + mockedService.On("TheExampleMethodFunctionalOptions", "test", FunctionalOptions(OpNum(1), OpStr("foo"))).Return(nil).Once() tt := new(testing.T) assert.False(t, mockedService.AssertExpectations(tt)) // make the call now - mockedService.TheExampleMethodFunctionalOptions("test") + TheExampleMethodFunctionalOptionsIndirect(mockedService) // now assert expectations assert.True(t, mockedService.AssertExpectations(tt)) From fb67df63928ed75bbececffbd748155d2620f290 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Thu, 24 Oct 2024 11:40:45 +0200 Subject: [PATCH 5/9] no regression --- mock/mock.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 487dca2b3..7ba05b754 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1205,12 +1205,6 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpts := reflect.ValueOf(expected) actualOpts := reflect.ValueOf(actual) - if expectedOpts.Len() != actualOpts.Len() { - expectedFmt = fmt.Sprintf("%v", expectedOpts) - actualFmt = fmt.Sprintf("%v", actualOpts) - return - } - var expectedNames []string for i := 0; i < expectedOpts.Len(); i++ { expectedNames = append(expectedNames, funcName(expectedOpts.Index(i).Interface())) @@ -1229,6 +1223,14 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpt := expectedOpts.Index(i).Interface() actualOpt := actualOpts.Index(i).Interface() + expectedFunc := expectedNames[i] + actualFunc := actualNames[i] + if expectedFunc != actualFunc { + expectedFmt = expectedFunc + actualFmt = actualFunc + return + } + ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value var actualValues []reflect.Value From be992afabf0732046a842caf78868376945ad245 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Thu, 24 Oct 2024 13:28:30 +0200 Subject: [PATCH 6/9] trial --- mock/mock.go | 54 +++++++++++++++++++++++++++-------------------- mock/mock_test.go | 2 +- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 7ba05b754..fe3510860 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1205,31 +1205,28 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpts := reflect.ValueOf(expected) actualOpts := reflect.ValueOf(actual) - var expectedNames []string - for i := 0; i < expectedOpts.Len(); i++ { - expectedNames = append(expectedNames, funcName(expectedOpts.Index(i).Interface())) - } - var actualNames []string - for i := 0; i < actualOpts.Len(); i++ { - actualNames = append(actualNames, funcName(actualOpts.Index(i).Interface())) - } - if !assert.ObjectsAreEqual(expectedNames, actualNames) { - expectedFmt = fmt.Sprintf("%v", expectedNames) - actualFmt = fmt.Sprintf("%v", actualNames) + if expectedOpts.Len() != actualOpts.Len() { + expectedFmt = fmt.Sprintf("%v", expected) + actualFmt = fmt.Sprintf("%v", actual) return } + var funcNames []string + for i := 0; i < expectedOpts.Len(); i++ { - expectedOpt := expectedOpts.Index(i).Interface() - actualOpt := actualOpts.Index(i).Interface() + expectedFunc := getRuntimeFunc(expectedOpts.Index(i).Interface()) + funcNames = append(funcNames, funcName(getRuntimeFunc(expectedFunc))) - expectedFunc := expectedNames[i] - actualFunc := actualNames[i] - if expectedFunc != actualFunc { - expectedFmt = expectedFunc - actualFmt = actualFunc + if actualFunc := getRuntimeFunc(actualOpts.Index(i).Interface()); !isFuncSame(expectedFunc, actualFunc) { + expectedFmt = funcName(expectedFunc) + actualFmt = funcName(actualFunc) return } + } + + for i := 0; i < expectedOpts.Len(); i++ { + expectedOpt := expectedOpts.Index(i).Interface() + actualOpt := actualOpts.Index(i).Interface() ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value @@ -1249,8 +1246,8 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { for i := 0; i < ot.NumIn(); i++ { if expectedArg, actualArg := expectedValues[i].Interface(), actualValues[i].Interface(); !assert.ObjectsAreEqual(expectedArg, actualArg) { - expectedFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], expectedArg, expectedArg) - actualFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], actualArg, actualArg) + expectedFmt = fmt.Sprintf("%s(%T) -> %#v", funcNames[i], expectedArg, expectedArg) + actualFmt = fmt.Sprintf("%s(%T) -> %#v", funcNames[i], actualArg, actualArg) return } } @@ -1259,9 +1256,13 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { return "", "" } -func funcName(opt interface{}) string { - n := runtime.FuncForPC(reflect.ValueOf(opt).Pointer()).Name() - trimmed := strings.TrimSuffix(path.Base(n), path.Ext(n)) +func getRuntimeFunc(opt interface{}) *runtime.Func { + return runtime.FuncForPC(reflect.ValueOf(opt).Pointer()) +} + +func funcName(f *runtime.Func) string { + name := f.Name() + trimmed := strings.TrimSuffix(path.Base(name), path.Ext(name)) splitted := strings.Split(trimmed, ".") if len(splitted) == 0 { @@ -1270,3 +1271,10 @@ func funcName(opt interface{}) string { return splitted[len(splitted)-1] } + +func isFuncSame(f1, f2 *runtime.Func) bool { + f1File, f1Loc := f1.FileLine(f1.Entry()) + f2File, f2Loc := f2.FileLine(f2.Entry()) + + return f1File == f2File && f1Loc == f2Loc +} diff --git a/mock/mock_test.go b/mock/mock_test.go index 71249239b..2de277371 100644 --- a/mock/mock_test.go +++ b/mock/mock_test.go @@ -1550,7 +1550,7 @@ func Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly(t *testing.T) } -func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Name(t *testing.T) { +func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Func(t *testing.T) { var mockedService = new(TestExampleImplementation) From ea7129e00694592e20cb34c58a6b8a251418b9da Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Sun, 27 Oct 2024 08:02:53 +0100 Subject: [PATCH 7/9] better fmt --- mock/mock.go | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index fe3510860..50eeaba03 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1205,21 +1205,31 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { expectedOpts := reflect.ValueOf(expected) actualOpts := reflect.ValueOf(actual) + var expectedFuncs []*runtime.Func + var expectedNames []string + for i := 0; i < expectedOpts.Len(); i++ { + f := runtimeFunc(expectedOpts.Index(i).Interface()) + expectedFuncs = append(expectedFuncs, f) + expectedNames = append(expectedNames, funcName(f)) + } + var actualFuncs []*runtime.Func + var actualNames []string + for i := 0; i < actualOpts.Len(); i++ { + f := runtimeFunc(actualOpts.Index(i).Interface()) + actualFuncs = append(actualFuncs, f) + actualNames = append(actualNames, funcName(f)) + } + if expectedOpts.Len() != actualOpts.Len() { - expectedFmt = fmt.Sprintf("%v", expected) - actualFmt = fmt.Sprintf("%v", actual) + expectedFmt = fmt.Sprintf("%v", expectedNames) + actualFmt = fmt.Sprintf("%v", actualNames) return } - var funcNames []string - for i := 0; i < expectedOpts.Len(); i++ { - expectedFunc := getRuntimeFunc(expectedOpts.Index(i).Interface()) - funcNames = append(funcNames, funcName(getRuntimeFunc(expectedFunc))) - - if actualFunc := getRuntimeFunc(actualOpts.Index(i).Interface()); !isFuncSame(expectedFunc, actualFunc) { - expectedFmt = funcName(expectedFunc) - actualFmt = funcName(actualFunc) + if !isFuncSame(expectedFuncs[i], actualFuncs[i]) { + expectedFmt = expectedNames[i] + actualFmt = actualNames[i] return } } @@ -1246,8 +1256,8 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { for i := 0; i < ot.NumIn(); i++ { if expectedArg, actualArg := expectedValues[i].Interface(), actualValues[i].Interface(); !assert.ObjectsAreEqual(expectedArg, actualArg) { - expectedFmt = fmt.Sprintf("%s(%T) -> %#v", funcNames[i], expectedArg, expectedArg) - actualFmt = fmt.Sprintf("%s(%T) -> %#v", funcNames[i], actualArg, actualArg) + expectedFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], expectedArg, expectedArg) + actualFmt = fmt.Sprintf("%s(%T) -> %#v", expectedNames[i], actualArg, actualArg) return } } @@ -1256,7 +1266,7 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { return "", "" } -func getRuntimeFunc(opt interface{}) *runtime.Func { +func runtimeFunc(opt interface{}) *runtime.Func { return runtime.FuncForPC(reflect.ValueOf(opt).Pointer()) } From 05f87c016035811e6d8371f1887ec360c318f53f Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Sun, 27 Oct 2024 08:05:00 +0100 Subject: [PATCH 8/9] more similar --- mock/mock.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 50eeaba03..9f24479cd 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1227,16 +1227,14 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { } for i := 0; i < expectedOpts.Len(); i++ { + expectedOpt := expectedOpts.Index(i).Interface() + actualOpt := actualOpts.Index(i).Interface() + if !isFuncSame(expectedFuncs[i], actualFuncs[i]) { expectedFmt = expectedNames[i] actualFmt = actualNames[i] return } - } - - for i := 0; i < expectedOpts.Len(); i++ { - expectedOpt := expectedOpts.Index(i).Interface() - actualOpt := actualOpts.Index(i).Interface() ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value From 7d99b2b43d8f60a8982a78cde6e8bd287dea5da0 Mon Sep 17 00:00:00 2001 From: Arjun Dhawan Date: Sun, 27 Oct 2024 08:07:57 +0100 Subject: [PATCH 9/9] attempt 2 --- mock/mock.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 9f24479cd..eb5682df9 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -1227,15 +1227,15 @@ func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt string) { } for i := 0; i < expectedOpts.Len(); i++ { - expectedOpt := expectedOpts.Index(i).Interface() - actualOpt := actualOpts.Index(i).Interface() - if !isFuncSame(expectedFuncs[i], actualFuncs[i]) { expectedFmt = expectedNames[i] actualFmt = actualNames[i] return } + expectedOpt := expectedOpts.Index(i).Interface() + actualOpt := actualOpts.Index(i).Interface() + ot := reflect.TypeOf(expectedOpt) var expectedValues []reflect.Value var actualValues []reflect.Value