Warning function is undefined

Hello, I have a strange warning when running my tests:

warning: function Parker.Test.FakeHTTPipe.get/2 is undefined (module Parker.Test.FakeHTTPipe is not available)
lib/parker/adapters/httpipe.ex:6

I’ve build a “fake” http library that should be used in my tests in substitution to HTTPipe.
This library is located under test/support and is loaded just before running the tests in test_helper.exs

Path.join([File.cwd!, "test", "support", "*"])
|> Path.wildcard
|> Enum.map(fn(file) -> Code.load_file(file) end)

and called by the app using config/test.exs and a variable that points to the configuration (pretty much the same as in http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/)
Am I supposed to Code.load_file somewhere else to make that warning disappear?

Thanks in advance, ngw

1 Like

In comments, in article you liked to is a solution. I do not think you need to use Code.load at all. Instead you can add the test/support to the compile path in test Mix.env and it should compile it / include properly.

Check out his example mixfile from Phoenix itself (also linked in the comments):
https://github.com/phoenixframework/phoenix/blob/master/installer/templates/new/mix.exs#L30-L31

2 Likes

Ahhh, and what’s funny is that I already had that, but of course it wasn’t working because in test/support I was writing .exs files…
Thanks a lot!

1 Like