Currently the documentation is clear and vibrant with the common HTTP
verbs, but we started implementing some HEAD
routes today and it is not tested the same way as the others.
To test say a GET
method:
conn = get conn, controller_path(conn, :controller_method, params)
So I would assume you would just change get
to head
, but this is not the case.
Here is my route:
template_journeys_count_path HEAD /v1/templates/:template_id/journeys GondorWeb.V1.JourneyController :count
and my controller method:
def count(conn, %{"template_id" => template_id}) do
count = Templates.get_journey_count(template_id)
conn
|> put_resp_header("x-total-count", count)
|> send_resp(204, "")
end
and my test:
conn = head conn, template_journeys_count_path(conn, :count, template.id)
assert response(conn, 204)
But I am getting an error saying no response received and the resp_header
that I added what not in conn.resp_headers
Am I missing something? I also tried to set up a connection build using Plug.ConnTest
's method build_conn
passing the HEAD
method into it but still no luck.