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

Function Test_Mock_UnsetByOnMethodSpec

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

Source from the content-addressed store, hash-verified

645}
646
647func Test_Mock_UnsetByOnMethodSpec(t *testing.T) {
648 t.Parallel()
649
650 // make a test impl object
651 var mockedService = new(TestExampleImplementation)
652
653 mock1 := mockedService.
654 On("TheExampleMethod", 1, 2, 3).
655 Return(0, nil)
656
657 assert.Equal(t, 1, len(mockedService.ExpectedCalls))
658 mock1.On("TheExampleMethod", 1, 2, 3).
659 Return(0, nil).Unset()
660
661 assert.Equal(t, 0, len(mockedService.ExpectedCalls))
662
663 assert.Panics(t, func() {
664 mock1.Unset()
665 })
666
667 assert.Equal(t, 0, len(mockedService.ExpectedCalls))
668}
669
670func Test_Mock_UnsetByOnMethodSpecAmongOthers(t *testing.T) {
671 t.Parallel()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected