-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Add introspection of which modules are currently mocked #210
Add introspection of which modules are currently mocked #210
Conversation
Feels like it would benefit from sharing part of implementation with |
I thought the same, but I wanted to prevent doing 2 passes over a (sub)list. |
❤️ If you are up for it, I would suggest some refactoring that allows us to re-use code in all scenarios:
This should keep the existing behaviour and then we can delete the old |
I really like the idea! I'll do the changes tonight and submit it :) |
Or |
|
There's already an `meck:expects/[1,2]`, allowing introspection into what kind of expectations are set. This allows one to also check which modules is meck handling at any point. Introduced a `foldl_mocks` internal function to reuse the same logic for both `unload/0` and `mocked/0`
I've updated the PR. |
@fcristovao Sorry, I did a later edit to |
Never mind, missed that you need the original module name, not the mock name! 🤦 |
However, I think you don't need your old expression since all modules are guaranteed to have the |
@eproxus Is your suggestion that the "foldl" functions should get the name of the modules in |
Thanks, great work! I really like the test as well! |
Fun :: fun((Elem :: module(), AccIn) -> AccOut), | ||
AccIn :: term(), | ||
AccOut :: term(). | ||
foldl_mocks(Fun, Acc0) when is_function(Fun, 2) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say l
in foldl
is not needed because the order is not defined :) See, for example, maps:fold / sets:fold
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll remove it on master.
There's already an
meck:expects/[1,2]
, allowing introspection intowhat kind of expectations are set.
This allows one to also check which modules is meck handling at any
point.