I’m attempting to test a plug that requires some request cookies to get set before the test runs. I’ve tried the following:
test "should return true when a sessionID cookie is present", %{conn: conn} do
Application.put_env(:myapp_interface, :cookie_prefix, "int")
conn = conn
|> put_req_cookie("intsessionID", "foobar")
|> Authorized.call([])
assert conn.assigns.authorized == true
end
Running that test results in the following error:
** (UndefinedFunctionError) function Plug.Conn.Unfetched.fetch/2 is undefined
(Plug.Conn.Unfetched does not implement the Access behavior)
I’m stuck trying to figure out what is going on here and what I’ve missed. Can someone either shed some light on what I’m doing wrong or point me to some documentation that shows the proper way to set up this test?