-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule Unplug.Predicates.RequestPathInTest do | ||
use ExUnit.Case, async: true | ||
use Plug.Test | ||
|
||
test "should return true if the expected value is in the request path list" do | ||
conn = conn(:get, "/healthcheck") | ||
|
||
assert Unplug.Predicates.RequestPathIn.call(conn, ["/metrics", "/healthcheck"]) | ||
end | ||
|
||
test "should return false if the expected value is not in the request path list" do | ||
conn = conn(:get, "/users") | ||
|
||
refute Unplug.Predicates.RequestPathIn.call(conn, ["/metrics", "/healthcheck"]) | ||
end | ||
|
||
test "should return true if the expected value is in the request path regex list" do | ||
conn = conn(:get, "/healthcheck") | ||
|
||
assert Unplug.Predicates.RequestPathIn.call(conn, ["/some_other_path", ~r/metrics/, ~r/healthcheck/]) | ||
end | ||
|
||
test "should return false if the expected value does not match the request path regex" do | ||
conn = conn(:get, "/users") | ||
|
||
refute Unplug.Predicates.RequestPathIn.call(conn, ["/some_other_path", ~r/metrics/, ~r/healthcheck/]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule Unplug.Predicates.RequestPathNotInTest do | ||
use ExUnit.Case, async: true | ||
use Plug.Test | ||
|
||
test "should return false if the expected value is in the request path list" do | ||
conn = conn(:get, "/healthcheck") | ||
|
||
refute Unplug.Predicates.RequestPathNotIn.call(conn, ["/metrics", "/healthcheck"]) | ||
end | ||
|
||
test "should return true if the expected value is not in the request path list" do | ||
conn = conn(:get, "/users") | ||
|
||
assert Unplug.Predicates.RequestPathNotIn.call(conn, ["/metrics", "/healthcheck"]) | ||
end | ||
|
||
test "should return false if the expected value is in the request path regex list" do | ||
conn = conn(:get, "/healthcheck") | ||
|
||
refute Unplug.Predicates.RequestPathNotIn.call(conn, ["/some_other_path", ~r/metrics/, ~r/healthcheck/]) | ||
end | ||
|
||
test "should return true if the expected value does not match the request path regex" do | ||
conn = conn(:get, "/users") | ||
|
||
assert Unplug.Predicates.RequestPathNotIn.call(conn, ["/some_other_path", ~r/metrics/, ~r/healthcheck/]) | ||
end | ||
end |