Closed hieunguyen1809 closed 1 year ago
I've got the same trouble :( Could you check and may be vote for my fix for this? https://github.com/stretchr/testify/pull/1250
For people who face this issue, i use this code
unset := func(call *mock.Call) {
if call != nil {
call.Parent.ExpectedCalls = []*mock.Call{}
}
}
var caller *mock.Call
unset(caller)
as temporary fix. you can try this to
Just fyi, I put short snippet which only specific method would be deleted based on @at-syot 's code
var unsetFn = func(call *mock.Call) {
if call != nil {
var newList []*mock.Call
for _, c := range call.Parent.ExpectedCalls {
if c.Method != call.Method {
newList = append(newList, c)
}
}
call.Parent.ExpectedCalls = newList
}
}
// caller side
unsetFn(mockInstance.On("SOME_METHOD_YOU_WANT_TO_UNSET"))
Hello @gordonlee . I have a fix #1250 but have no permission merge it. Could you help promote it?
Running in the same problem. A fix would be appreciated 😄
Hi team, I'm using testify to testing my method but encounter this issue (It only occur if using matchedBy arg) When I using mock following by example but got error when using mockCall.Unset(). playground: https://go.dev/play/p/oQ2sGSRCtbR