-
Notifications
You must be signed in to change notification settings - Fork 77
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 Mox.get_executed_calls/1 #140
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,7 +189,7 @@ defmodule Mox do | |
when the allowance happens. In such a case, you might specify the allowance | ||
as a function in the form `(-> pid())`. This function would be resolved late, | ||
at the very moment of dispatch. If the function does not return an existing | ||
PID, it will fail `Mox.UnexpectedCallError`. | ||
PID, it will fail `Mox.UnexpectedCallError`. | ||
|
||
### Global mode | ||
|
||
|
@@ -763,6 +763,11 @@ defmodule Mox do | |
verify_mock_or_all!(self(), mock, :test) | ||
end | ||
|
||
def get_executed_calls(mock) do | ||
validate_mock!(mock) | ||
Mox.Server.get_executed_calls(mock) | ||
end | ||
|
||
defp verify_mock_or_all!(pid, mock, test_or_on_exit) do | ||
pending = Mox.Server.verify(pid, mock, test_or_on_exit) | ||
|
||
|
@@ -812,7 +817,7 @@ defmodule Mox do | |
def __dispatch__(mock, name, arity, args) do | ||
all_callers = [self() | caller_pids()] | ||
|
||
case Mox.Server.fetch_fun_to_dispatch(all_callers, {mock, name, arity}) do | ||
case Mox.Server.fetch_fun_to_dispatch(all_callers, {mock, name, arity}, args) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means we are copying all argument data to a separate process. :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, is that an issue in tests? We would do the same when using the Any ideas on how to do this without copying the args? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem is that this enables this for everything by default. We would need to store it somewhere if we want to collect or not. |
||
:no_expectation -> | ||
mfa = Exception.format_mfa(mock, name, arity) | ||
|
||
|
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.
Also, is this safe to execute concurrently? It doesn't look like it is the case. :(
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.
It definitely isn't 😉 Will have to figure it out with the allowance.