towerops/test/towerops_web/endpoint/body_reader_test.exs
Graham McIntire 03ec909e3a test: add LiveView tests following testing-liveview patterns
Apply Testing LiveView course patterns (live/2, has_element?,
render_click, form/3). Add tests for MobileQRLive, WeathermapLive,
StatusPageLive, controllers, plugs, and pure function modules.
Expand proto decode coverage to 85.24%.
2026-05-07 12:55:39 -05:00

25 lines
773 B
Elixir

defmodule ToweropsWeb.Endpoint.BodyReaderTest do
use ToweropsWeb.ConnCase, async: true
alias ToweropsWeb.Endpoint.BodyReader
describe "read_body/2" do
test "passes through non-protobuf body", %{conn: conn} do
conn =
conn
|> put_req_header("content-type", "application/json")
|> Plug.Conn.put_private(:raw_body, nil)
conn = Plug.Conn.assign(conn, :plug_body_reader, {BodyReader, :read_body, []})
{:ok, body, _conn} = BodyReader.read_body(conn, [])
assert is_binary(body)
end
test "skips body parsing for protobuf content type", %{conn: conn} do
conn = put_req_header(conn, "content-type", "application/x-protobuf")
assert {:ok, "", ^conn} = BodyReader.read_body(conn, [])
end
end
end