Open
Description
PrivateMethodStruct add two private methods:
func (this *PrivateMethodStruct) lastError() error{
return nil
}
func (this *PrivateMethodStruct) LastError() error{
return this.lastError()
}
TestApplyPrivateMethod add test below:
Convey("patch private method return interface", func() {
f := new(fake.PrivateMethodStruct)
var s *fake.PrivateMethodStruct
pErr := errors.New("error")
patches := ApplyPrivateMethod(s, "lastError", func() error {
return pErr
})
defer patches.Reset()
result := f.LastError()
So(result, ShouldEqual, pErr)
})
we got a panic: invalid memory address or nil pointer dereference
Metadata
Metadata
Assignees
Labels
No labels