Documentation
¶
Overview ¶
Package mockpanicking provides mock implementations of the panicking package's interfaces. Both the hand-written testify-based Panicker and the moq-generated PanickerMock live here during the testify → moq migration. New test code should prefer PanickerMock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PanickerMock ¶
type PanickerMock struct {
// PanicFunc mocks the Panic method.
PanicFunc func(v any)
// PanicfFunc mocks the Panicf method.
PanicfFunc func(format string, args ...any)
// contains filtered or unexported fields
}
PanickerMock is a mock implementation of panicking.Panicker.
func TestSomethingThatUsesPanicker(t *testing.T) {
// make and configure a mocked panicking.Panicker
mockedPanicker := &PanickerMock{
PanicFunc: func(v any) {
panic("mock out the Panic method")
},
PanicfFunc: func(format string, args ...any) {
panic("mock out the Panicf method")
},
}
// use mockedPanicker in code that requires panicking.Panicker
// and then make assertions.
}
func (*PanickerMock) PanicCalls ¶
func (mock *PanickerMock) PanicCalls() []struct { V any }
PanicCalls gets all the calls that were made to Panic. Check the length with:
len(mockedPanicker.PanicCalls())
func (*PanickerMock) Panicf ¶
func (mock *PanickerMock) Panicf(format string, args ...any)
Panicf calls PanicfFunc.
func (*PanickerMock) PanicfCalls ¶
func (mock *PanickerMock) PanicfCalls() []struct { Format string Args []any }
PanicfCalls gets all the calls that were made to Panicf. Check the length with:
len(mockedPanicker.PanicfCalls())
Click to show internal directories.
Click to hide internal directories.