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

Function Test_Mock_Unset

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

Source from the content-addressed store, hash-verified

558}
559
560func Test_Mock_Unset(t *testing.T) {
561 t.Parallel()
562
563 // make a test impl object
564 var mockedService = new(TestExampleImplementation)
565
566 call := mockedService.
567 On("TheExampleMethodFuncType", "argA").
568 Return("blah")
569
570 found, foundCall := mockedService.findExpectedCall("TheExampleMethodFuncType", "argA")
571 require.NotEqual(t, -1, found)
572 require.Equal(t, foundCall, call)
573
574 call.Unset()
575
576 found, foundCall = mockedService.findExpectedCall("TheExampleMethodFuncType", "argA")
577 require.Equal(t, -1, found)
578
579 var expectedCall *Call
580 require.Equal(t, expectedCall, foundCall)
581
582 fn := func(string) error { return nil }
583 assert.Panics(t, func() {
584 mockedService.TheExampleMethodFuncType(fn)
585 })
586}
587
588// Since every time you call On it creates a new object
589// the last time you call Unset it will only unset the last call

Callers

nothing calls this directly

Calls 8

NotEqualFunction · 0.92
EqualFunction · 0.92
PanicsFunction · 0.92
ReturnMethod · 0.80
findExpectedCallMethod · 0.80
UnsetMethod · 0.80
OnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…