stretchr / testify

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

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

Open st3penta opened 3 months ago

st3penta commented 3 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