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

Function Test_Mock_UnsetIfAlreadyUnsetFails

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

Source from the content-addressed store, hash-verified

624}
625
626func Test_Mock_UnsetIfAlreadyUnsetFails(t *testing.T) {
627 t.Parallel()
628
629 // make a test impl object
630 var mockedService = new(TestExampleImplementation)
631
632 mock1 := mockedService.
633 On("TheExampleMethod1", 1, 1).
634 Return(1)
635
636 assert.Equal(t, 1, len(mockedService.ExpectedCalls))
637 mock1.Unset()
638 assert.Equal(t, 0, len(mockedService.ExpectedCalls))
639
640 assert.Panics(t, func() {
641 mock1.Unset()
642 })
643
644 assert.Equal(t, 0, len(mockedService.ExpectedCalls))
645}
646
647func Test_Mock_UnsetByOnMethodSpec(t *testing.T) {
648 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