Elixir / Plug / Phoenix: stopping a call does not stop downstream plugs after a call during a test

If I launched an instance of my phoenix application and typed it with requests, my plugins would stop accordingly. However, doing the same if the test environment stops does not stop the downstream plug-ins, which leads to the failure of my tests. I think that the problem may arise due to the fact that I call the router during my test. Here we use an auxiliary function, which is heavily borrowed from a similar function in the phoenix system itself:

def call(router, verb, path, params \\ nil, headers \\ []) do
    add_headers(conn(verb, path, params), headers)
    |> Plug.Conn.fetch_params
    |> Plug.Parsers.call(parsers: [Plug.Parsers.JSON],
                    pass: ["*/*"],
                    json_decoder: Poison)
    |> router.call(router.init([]))
  end

Any ideas on why calling my router like this leads to a shutdown?

EDIT: So, I am upgrading to Phoenix 0.13.1 to use the new endpoint testing module instead of what I used. I will talk about whether this fixes the problem or not.

+4
source share
1 answer

haltonly works inside the plug of the plug. If you manually connect the handset, you will need to manually check for a stop.

Honestly, I would dump your current pipeline and just call the actual endpoint from your tests. The endpoint pipeline is very fast; you shouldn't see it slowing down.

+4
source

All Articles