feat: Official plug API
Some checks failed
CI / Test (OTP 27.2 / Elixir 1.18.2) (push) Failing after 0s
CI / Test (OTP 28.4 / Elixir 1.19.4 + E2E) (push) Failing after 0s

This commit is contained in:
2026-03-20 01:31:57 +01:00
parent be9d348660
commit c446b8596a
8 changed files with 208 additions and 21 deletions

View File

@@ -0,0 +1,43 @@
defmodule Parrhesia.PlugTest do
use ExUnit.Case, async: true
import Plug.Test
alias Parrhesia.Plug
test "init resolves configured listener id" do
opts = Plug.init(listener: :public)
assert is_list(opts)
assert Keyword.fetch!(opts, :listener).id == :public
end
test "init accepts inline listener map" do
opts =
Plug.init(
listener: %{
id: :host_mount,
features: %{nostr: %{enabled: true}}
}
)
assert Keyword.fetch!(opts, :listener).id == :host_mount
end
test "init raises for unknown listener id" do
assert_raise ArgumentError, ~r/listener :does_not_exist not found/, fn ->
Plug.init(listener: :does_not_exist)
end
end
test "call serves health route" do
opts = Plug.init(listener: :public)
response =
conn(:get, "/health")
|> Plug.call(opts)
assert response.status == 200
assert response.resp_body == "ok"
end
end