Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need ability to set that not calling "done()" on a mock is expected #116

Closed
ShakenCodes opened this issue May 16, 2024 · 3 comments
Closed

Comments

@ShakenCodes
Copy link

There are cases in testing where calling "done()" on the Mock is not practical within the given test case, and it would be useful to be able to tell the Mock to not expect done() to be called and to not emit a warning in that case.

This came up in porting the @eldruin's mlx9061x-rs to embedded-hal 1.0
Failing test cases are here: https://github.com/Radiator-Labs/mlx9061x-rs/actions/runs/9104910268/job/25029588644

The tests that fail are calling a fallible object create, which does not release the Mock and does not return the object when the creation fails. This means there is nothing to call done() on. Other test cases are able to call .destroy().done() on the returned object, which calls done() on the mock in the test context.

@dbrgn
Copy link
Owner

dbrgn commented May 16, 2024

You should be able to pass a clone of the mock to the driver, and then call .done() on your copy, right?

(The mock has an Arc internally, so only a reference is being cloned.)

@ShakenCodes
Copy link
Author

That sounds great. I'll give it a try right now.

@ShakenCodes
Copy link
Author

Using clone() solves my issue. I am closing this request.

Thank you for the assist!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants