Skip to content

Commit 98ac0d2

Browse files
committed
test: add mock server
1 parent 6c7f6c0 commit 98ac0d2

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

lib/web_push_elixir/application.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
defmodule WebPushElixir.Application do
2+
use Application
3+
4+
def start(_type, _args) do
5+
children = [
6+
{DynamicSupervisor, name: WebPushElixir.DynamicSupervisor}
7+
]
8+
9+
opts = [strategy: :one_for_one, name: WebPushElixir.Supervisor]
10+
Supervisor.start_link(children, opts)
11+
end
12+
end

lib/web_push_elixir/mock_server.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
defmodule WebPushElixir.MockServer do
2+
use Plug.Router
3+
4+
plug(:match)
5+
plug(:dispatch)
6+
7+
post "/some-endpoint" do
8+
conn
9+
|> Plug.Conn.send_resp(200, "ok")
10+
end
11+
end

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ defmodule WebPushElixir.MixProject do
1414
# Run "mix help compile.app" to learn about applications.
1515
def application do
1616
[
17+
mod: {WebPushElixir.Application, []},
1718
extra_applications: [:logger]
1819
]
1920
end

test/test_helper.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
ExUnit.start()
2+
3+
DynamicSupervisor.start_child(WebPushElixir.DynamicSupervisor, {Plug.Cowboy, scheme: :http, plug: WebPushElixir.MockServer, options: [port: 4040]})

0 commit comments

Comments
 (0)