我想测试这个功能
type yourCustomStruct struct {
yourMock
}
func (s *yourCustomStruct) Load(token string) (*MyObj, error) {
s.yourMock.Called(token)
if isValid(token) {
return someStuff(), nil
} else {
return nil, errors.New("Oh!")
}
}
当我像这样使用作证模拟时
yourCustomStructMock.On("Load", mock.Anything).Return(nil, errors.New("Oh!"))
我得到这样的错误 panic: interface conversion: interface {} is nil, not *MyObj[recovered] panic: interface conversion: interface {} is nil, not *MyObj