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

Function Test_Mock_findExpectedCall_Respects_Repeatability

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

Source from the content-addressed store, hash-verified

1278}
1279
1280func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) {
1281 t.Parallel()
1282
1283 m := new(Mock)
1284 m.On("One", 1).Return("one")
1285 m.On("Two", 2).Return("two").Once()
1286 m.On("Two", 3).Return("three").Twice()
1287 m.On("Two", 3).Return("three").Times(8)
1288
1289 f, c := m.findExpectedCall("Two", 3)
1290
1291 if assert.Equal(t, 2, f) {
1292 if assert.NotNil(t, c) {
1293 assert.Equal(t, "Two", c.Method)
1294 assert.Equal(t, 3, c.Arguments[0])
1295 assert.Equal(t, "three", c.ReturnArguments[0])
1296 }
1297 }
1298
1299 c = m.On("Once", 1).Return("one").Once()
1300 c.Repeatability = -1
1301 f, c = m.findExpectedCall("Once", 1)
1302 if assert.Equal(t, -1, f) {
1303 if assert.NotNil(t, c) {
1304 assert.Equal(t, "Once", c.Method)
1305 assert.Equal(t, 1, c.Arguments[0])
1306 assert.Equal(t, "one", c.ReturnArguments[0])
1307 }
1308 }
1309}
1310
1311func Test_callString(t *testing.T) {
1312 t.Parallel()

Callers

nothing calls this directly

Calls 8

EqualFunction · 0.92
NotNilFunction · 0.92
ReturnMethod · 0.80
OnceMethod · 0.80
TwiceMethod · 0.80
TimesMethod · 0.80
findExpectedCallMethod · 0.80
OnMethod · 0.45

Tested by

no test coverage detected