MCPcopy
hub / github.com/stretchr/testify / Test_Mock_Chained_On

Function Test_Mock_Chained_On

mock/mock_test.go:189–220  ·  mock/mock_test.go::Test_Mock_Chained_On
(t *testing.T)

Source from the content-addressed store, hash-verified

187}
188
189func Test_Mock_Chained_On(t *testing.T) {
190 t.Parallel()
191
192 // make a test impl object
193 var mockedService = new(TestExampleImplementation)
194
195 // determine our current line number so we can assert the expected calls callerInfo properly
196 _, filename, line, _ := runtime.Caller(0)
197 mockedService.
198 On("TheExampleMethod", 1, 2, 3).
199 Return(0).
200 On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).
201 Return(nil)
202
203 expectedCalls := []*Call{
204 {
205 Parent: &mockedService.Mock,
206 Method: "TheExampleMethod",
207 Arguments: []interface{}{1, 2, 3},
208 ReturnArguments: []interface{}{0},
209 callerInfo: []string{fmt.Sprintf("%s:%d", filename, line+2)},
210 },
211 {
212 Parent: &mockedService.Mock,
213 Method: "TheExampleMethod3",
214 Arguments: []interface{}{AnythingOfType("*mock.ExampleType")},
215 ReturnArguments: []interface{}{nil},
216 callerInfo: []string{fmt.Sprintf("%s:%d", filename, line+4)},
217 },
218 }
219 assert.Equal(t, expectedCalls, mockedService.ExpectedCalls)
220}
221
222func Test_Mock_On_WithArgs(t *testing.T) {
223 t.Parallel()

Callers

nothing calls this directly

Calls 4

EqualFunction · 0.92
AnythingOfTypeFunction · 0.85
ReturnMethod · 0.80
OnMethod · 0.45

Tested by

no test coverage detected