stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
23.55k stars 1.6k forks source link

mock: clear call from NotBefore expectations on Unset() #1572

Open st3penta opened 8 months ago

st3penta commented 8 months ago

Summary

The Call.Unset method was not properly clearing the dependency established by the CallB.NotBefore(CallA) method, which stipulates that CallA should precede CallB. Consequently, the expectations for CallB were failing because it was still anticipating CallA.

Changes

This PR adds the field requiredBy to the Call object, that tracks the dependent Call instances (e.g: CallB, in the above example). This field is used in the Unset method to clear the NotBefore expectations from the dependent calls.

Related issues

Closes #1542