You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there! I found this library via this blog post and wanted to include it in my project.
One thing I've found is that it doesn't seem to support rewiring modules where the modules must us as:. Here's an example based on a real-world issue that I'm running up against during a refactor:
defmoduleFoodo# See they have the same final name part so I _must_ use `as:`aliasFoo.YtDlp.CommandRunner,as: YtDlpRunneraliasFoo.Apprise.CommandRunner,as: AppriseRunnerdefyt_dlp_bar,do: YtDlpRunner.bar()defapprise_baz,do: AppriseRunner.baz()# ...end
These are both modules that interface with CLI programs. Currently I'm using the standard Mox-recommended method of DI, but I dislike that it puts testing concerns in my main app code. I was hoping I could do something like this using rewire in my tests:
Which only overwrites the as: alias, but it's still ultimately pointing to the original modules.
Is there a way to handle this and I just missed it? If not, would you be open to a PR that handles this case? This would be a breaking change but I think it's a valuable one
The text was updated successfully, but these errors were encountered:
I must preface this by saying I haven't looked at this library in years. From your description and looking at the test cases again, I fully agree that it would be better to rewrite the alias import, not just the as: part. Actually, it seems to me like an oversight/a bug rather than a design choice. So I'd welcome a PR here!
Hey there! I found this library via this blog post and wanted to include it in my project.
One thing I've found is that it doesn't seem to support rewiring modules where the modules must us
as:
. Here's an example based on a real-world issue that I'm running up against during a refactor:These are both modules that interface with CLI programs. Currently I'm using the standard Mox-recommended method of DI, but I dislike that it puts testing concerns in my main app code. I was hoping I could do something like this using rewire in my tests:
But that doesn't seem to be possible. I could be missing something, but in my testing it seems like the AST is functionally rewritten to this:
Which only overwrites the
as:
alias, but it's still ultimately pointing to the original modules.Is there a way to handle this and I just missed it? If not, would you be open to a PR that handles this case? This would be a breaking change but I think it's a valuable one
The text was updated successfully, but these errors were encountered: