Function is undefined or private

Hi all

I am using bypass to create a http mock server for test.

  setup do
    bypass = 3000)
    {:ok, bypass: bypass}

As you can see, the port is set to 3000 and when I start the test, I’ve got following error:

  1) test Handle user login. (SapOdataService.Auth.UserLoginTest)
     ** (UndefinedFunctionError) function is undefined or private. Did you mean one of:

           * open/0

       (bypass)[port: 3000])
       test/auth/user_login_test.exs:9: SapOdataService.Auth.UserLoginTest.__ex_unit_setup_0/1
       test/auth/user_login_test.exs:1: SapOdataService.Auth.UserLoginTest.__ex_unit__/2

What am I doing wrong?


it looks like is not in a released version yet. you might need to include bypass from github in your mix.exs ({:bypass, github: "PSPDFKit-labs/bypass"}

Fist of all, thanks for your answer. Now an other problem occurs:

  1) test Handle user login. (SapOdataService.Auth.UserLoginTest)
     ** (exit) exited in:, {:new_request, #PID<0.222.0>, #Reference<>, {:client, :undefined, {:metrics_ng, :metrics_dummy}, :hackney_tcp, 'localhost', 3000, "localhost:3000", [], nil, nil, nil, true, :hackney_pool, 5000, false, 5, false, 5, nil, nil, nil, :undefined, :start, nil, :normal, false, false, false, :undefined, false, nil, :waiting, nil, 4096, "", [], :undefined, nil, nil, nil, nil, :undefined, nil}}, :infinity)
         ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
       (stdlib) gen_server.erl:212:
       src/hackney_manager.erl:66: :hackney_manager.init_request/1
       src/hackney_manager.erl:56: :hackney_manager.new_request/1
       src/hackney_connect.erl:185: :hackney_connect.socket_from_pool/4
       src/hackney_connect.erl:37: :hackney_connect.connect/5
       src/hackney.erl:328: :hackney.request/5
       lib/httpoison/base.ex:422: HTTPoison.Base.request/9
       (sap_odata_service) lib/auth/user_login.ex:21: SapOdataService.Protocols.Auth.SapOdataService.Auth.UserLogin.sign_in/1
       test/auth/user_login_test.exs:50: (test)


Finished in 0.1 seconds
2 tests, 1 failure

It seems like you’ve ommited

# test/test_helper.exs

And hackney application as a dependency was not started correctly.

I used bypass recently and encountered the same issues you have. For an example of how I ended up using it feel free to have a look through this.

The actual usage in the test

You will also need this in your test helper file

And this is the dependency I am using
{:bypass, git: "", only: :test}

1 Like

Thanks so much.

No problem.

I am hoping a new release of bypass might happen at some point, but it looks as though no one is actively maintaining it sadly :icon_sad:

1 Like