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

Function Test_Mock_On_WithFuncArg

mock/mock_test.go:235–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

233}
234
235func Test_Mock_On_WithFuncArg(t *testing.T) {
236 t.Parallel()
237
238 // make a test impl object
239 var mockedService = new(TestExampleImplementation)
240
241 c := mockedService.
242 On("TheExampleMethodFunc", AnythingOfType("func(string) error")).
243 Return(nil)
244
245 assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
246 assert.Equal(t, "TheExampleMethodFunc", c.Method)
247 assert.Equal(t, 1, len(c.Arguments))
248 assert.Equal(t, AnythingOfType("func(string) error"), c.Arguments[0])
249
250 fn := func(string) error { return nil }
251
252 assert.NotPanics(t, func() {
253 mockedService.TheExampleMethodFunc(fn)
254 })
255}
256
257func Test_Mock_On_WithIntArgMatcher(t *testing.T) {
258 t.Parallel()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected