We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hey!
I have a project where we use Mimic to copy a few modules, worked perfectly until we tried to copy a module that was basically a NIF module:
# nif module defmodule Core.Crypto.Ethereum do use Rustler, otp_app: :core, crate: :core_crypto_ethereum def ens_lookup_address(_), do: :erlang.nif_error(:nif_not_loaded) end # test_helpers.exs # ... # a bunch of Mimic.copy/1 calls here Mimic.copy(Core.Crypto.Ethereum) ExUnit.start() # test: defmodule MyTest do use Core.DataCase, async: true import Mimic describe "some function" do test "example" do expect(Core.Crypto.Ethereum, :ens_lookup_address, fn _ -> {:ok, "example.eth"} end) assert true end end end
Output:
** (ArgumentError) Module Core.Crypto.Ethereum has not been copied. See docs for Mimic.copy/1 code: expect(Ethereum, :ens_lookup_address, fn _addr -> {:ok, "example.eth"} end) stacktrace: (mimic 1.7.4) lib/mimic.ex:498: Mimic.validate_server_response/2 test/core/services/my_test.exs:49: (test) # ... 18:43:45.063 [error] GenServer Mimic.Server terminating ** (stop) {:error_loading_module, Core.Crypto.Ethereum.Mimic.Original.Module, :on_load_failure} (mimic 1.7.4) lib/mimic/module.ex:87: Mimic.Module.load_binary/3 (mimic 1.7.4) lib/mimic/module.ex:57: Mimic.Module.rename_module/2 (mimic 1.7.4) lib/mimic/module.ex:34: Mimic.Module.replace!/1 (mimic 1.7.4) lib/mimic/server.ex:504: Mimic.Server.ensure_module_copied/2 (mimic 1.7.4) lib/mimic/server.ex:360: Mimic.Server.handle_call/3 (stdlib 4.0.1) gen_server.erl:1146::gen_server.try_handle_call/4 (stdlib 4.0.1) gen_server.erl:1175::gen_server.handle_msg/6 (stdlib 4.0.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3 Last message (from #PID<0.2767.0>): {:expect, {Core.Crypto.Ethereum, :ens_lookup_address, #Function<4.71929683/1 in Core.MyTest."test example"/1>, 1}, 1, #PID<0.2767.0>}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hey!
I have a project where we use Mimic to copy a few modules, worked perfectly until we tried to copy a module that was basically a NIF module:
Output:
The text was updated successfully, but these errors were encountered: