Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plug.Router tests #1234

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions test/plug/router_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,32 @@ defmodule Plug.RouterTest do
%{route: "/", conn: %Plug.Conn{}, router: Sample}}
end

test "error is raised with expected message when match/3 is not given :to or :do option" do
assert_raise ArgumentError, "expected one of :to or :do to be given as option", fn ->
defmodule NoExpectedMatchOptions do
use Plug.Router

plug :match
plug :dispatch

match "/", foo: :bar
end
end
end

test "error is raised with expected message when no routes are defined" do
assert_raise RuntimeError,
"no routes defined in module Plug.RouterTest.NoRoutes using Plug.Router",
fn ->
defmodule NoRoutes do
use Plug.Router

plug :match
plug :dispatch
end
end
end

defp attach(handler_id, event) do
:telemetry.attach(
handler_id,
Expand Down