mandarvaze
I am facing a unique(?) problem.
I have unit tests and integration tests
Both call the same set of functions.
All the integration tests pass (mix test --include integration test/integration/gateways/mercadopago_test.exs)
All the unit tests fail (mix test test/gateways/mercadopago_test.exs)
For every unit test , I get the same error :
** (UndefinedFunctionError) function HTTPoison.request/5 is undefined (module HTTPoison is not available)
Stack trace points to lib/gringotts/gateways/mercadopago.ex:264: Gringotts.Gateways.Mercadopago.commit/5
Searching for module not available points to solutions that do not apply.
Most suggest including httpoison in mix.exs - which was already have (gringotts/mix.exs at mercadopago-2020 · aviabird/gringotts · GitHub)
Other suggestion is about elixirc_paths - which also taken care of (gringotts/mix.exs at mercadopago-2020 · aviabird/gringotts · GitHub)
BTW, I’m a n00b at elixir, so I may be overlooking something obvious.
I’ve already asked for helped in local elixir discord channel. No luck.
Thanks for any suggestions/ideas.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
So, many versions of Elixir ago, you had to manage the applications list as you are doing here. That is no longer true and will cause issues. I’d remove that line entirely.
Have you tried the simple
rm -rf _buildand recompile approach?Also, what version of elixir are you running?
elixir --versionmandarvaze
BTW, this is the highest version I can use. (project’s
travis.ymluses 1.5.3/1.6.5)I tried
rm -rf _buildfollowed directly bymix test test/gateways/mercadopago_test.exsSame results
axelson
I’m pretty sure that your test errors are related to the use of the
Mocklibrary, but I’m not sure what the resolution would be if you still want to use the library (I’m generally not a fan of that approach to mocking). Also running the tests under Elixir 1.10.2 with Erlang 22.1.7 I get the following error:** (ErlangError) Erlang error: {:compile_forms, {:error, [{[], [{:none, :compile, {:crash, :sys_core_fold, {{:case_clause, {:EXIT, {:function_clause, [{:sys_core_fold, :module, [[{:attribute, 44, :file, {'lib/httpoison.ex', 44}}, {:attribute, 44, :module, HTTPoison_meck_original}, {:attribute, 44, :compile, [:no_auto_import]}, {:attribute, 66, :spec, {{:transformer, 1}, [{:type, 66, :fun, [{:type, 66, :product, [{:type, 66, :pid, ...}]}, {:atom, 0, :ok}]}]}}, {:attribute, 66, :spec, {{:stream_next, 1}, [{:type, 66, :fun, [{:type, 66, :product, [{:remote_type, 66, ...}]}, {:type, 66, :union, [{:type, ...}, {...}]}]}]}}, {:attribute, 66, :spec, {{:request!, 5}, [{:type, 66, :fun, [{:type, 66, :product, [{:type, ...}, {...}, ...]}, {:type, 66, :union, [{...}, ...]}]}]}}, {:attribute, 66, :spec, {{:request, 5}, [{:type, 66, :fun, [{:type, 66, :product, [{...}, ...]}, {:type, 66, :union, [...]}]}]}}, {:attribute, 66, :spec, {{:put!, 4}, [{:type, 66, :fun, [{:type, 66, :product, [...]}, {:type, 66, :union, ...}]}]}}, {:attribute, 66, :spec, {{:put, 4}, [{:type, 66, :fun, [{:type, 66, :product, ...}, {:type, 66, ...}]}]}}, {:attribute, 66, :spec, {{:process_response_body, 1}, [{:type, 66, :fun, [{:type, 66, ...}, {:type, ...}]}]}}, {:attribute, 66, :spec, {{:process_request_headers, 1}, [{:type, 66, :fun, [{:type, ...}, {...}]}]}}, {:attribute, 66, :spec, {{:process_request_body, 1}, [{:type, 66, :fun, [{...}, ...]}]}}, {:attribute, 66, :spec, {{:post!, 4}, [{:type, 66, :fun, [...]}]}}, {:attribute, 66, :spec, {{:post, 4}, [{:type, 66, :fun, ...}]}}, {:attribute, 66, :spec, {{:patch!, 4}, [{:type, 66, ...}]}}, {:attribute, 66, :spec, {{:patch, 4}, [{:type, ...}]}}, {:attribute, 66, :spec, {{:options!, 3}, [{...}]}}, {:attribute, 66, :spec, {{:options, ...}, [...]}}, {:attribute, 66, :spec, {{...}, ...}}, {:attribute, 66, :spec, {...}}, {:attribute, 66, :spec, ...}, {:attribute, 66, ...}, {:attribute, ...}, {...}, ...], [:binary, :return_errors, :debug_info, :no_spawn_compiler_process, :from_core, :no_auto_import]], [file: 'sys_core_fold.erl', line: 109]}, {:compile, :"-select_passes/2-anonymous-2-", 3, [file: 'compile.erl', line: 675]}, {:compile, :"-internal_comp/5-anonymous-1-", 3, [file: 'compile.erl', line: 399]}, {:compile, :fold_comp, 4, [file: 'compile.erl', line: 426]}, {:compile, :internal_comp, 5, [file: 'compile.erl', line: 410]}, {:compile, :"-do_compile/2-anonymous-0-", 2, [file: 'compile.erl', line: 207]}, {:meck_code, :compile_and_load_forms, 2, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_code.erl', line: 71]}, {:meck_proc, :backup_original, 3, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_proc.erl', line: 363]}, {:meck_proc, :init, 1, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_proc.erl', line: 206]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}}, [{:compile, :"-select_passes/2-anonymous-2-", 3, [file: 'compile.erl', line: 675]}, {:compile, :"-internal_comp/5-anonymous-1-", 3, [file: 'compile.erl', line: 399]}, {:compile, :fold_comp, 4, [file: 'compile.erl', line: 426]}, {:compile, :internal_comp, 5, [file: 'compile.erl', line: 410]}, {:compile, :"-do_compile/2-anonymous-0-", 2, [file: 'compile.erl', line: 207]}, {:meck_code, :compile_and_load_forms, 2, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_code.erl', line: 71]}, {:meck_proc, :backup_original, 3, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_proc.erl', line: 363]}, {:meck_proc, :init, 1, [file: '/home/jason/dev/forks/tmp/gringotts/deps/meck/src/meck_proc.erl', line: 206]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}}]}], []}}mandarvaze
As I mentioned, we can’t use latest Elixir/Erlang. I tried 1.9.x (at first) and I too got errors, though I don’t remember what those were.
Even 1.8 wouldn’t work.
Anyway - why do you think this is related to
Mocklibrary ?There are two more payment gateway integrations authorize.net and cams in the same repo.
Their unit tests pass successfully
al2o3cr
All the unit tests start with a similar structure:
that’s mocking the
postfunction onHTTPoison. But the line that’s failing is using a lower-level HTTPoison function:Under the hood,
HTTPoison.postcallsHTTPoison.request:https://github.com/edgurgel/httpoison/blob/fc22bf8c5142015b7f8cd70737b51fd97a9d9206/lib/httpoison/base.ex#L273
Also note this important detail from the Mock documentation
mandarvaze
@al2o3cr What you say makes sense. I’m gonna use
Bypassinstead of MockBut I’m wondering why do other two test (files) for cams and authorize.net that use similar pattern (and Mock) work ?I confirmed that these two directly useHTTPoison.postinsidecommitfunction - hence theirwith_mockblock works.