agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.92k stars 178 forks source link

applyFunc failed due to type errors #121

Closed randompickfree closed 1 year ago

randompickfree commented 1 year ago

I recently upgraded go monkey to github.com/agiledragon/gomonkey/v2 v2.2.0. There is a test used to be working fine but is failing. { patch := gomonkey.NewPatches() defer patch.Reset() patch.ApplyFunc(xxfunc, func(_ context.Context, req model.XxReq) model.XxResult { return &model.XxResult{ ErrCode: 0, Message: &model.Message{ Message: model.PASS, }, } }) } I am getting error message like the following: target type(func(context.Context, model.XxReq, ...callopt.Option) model.XxResult) and double type(func(context.Context, model.XxReq) *model.XxResult) are different [recovered]

randompickfree commented 1 year ago

found out, xxFunc upgraded to add one more input, therefore causing this error