diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..5c46c3b --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +erlang 27.3.4.3 +elixir 1.18.4-otp-27 diff --git a/mix.exs b/mix.exs index c9b752b..2e9b991 100644 --- a/mix.exs +++ b/mix.exs @@ -6,6 +6,7 @@ defmodule WebPushElixir.MixProject do app: :web_push_elixir, version: "0.4.0", elixir: "~> 1.15", + elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, deps: deps(), description: "Simple web push for Elixir", @@ -25,16 +26,20 @@ defmodule WebPushElixir.MixProject do ] end + # Specifies which paths to compile per environment. + defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(_), do: ["lib"] + # Run "mix help deps" to learn about dependencies. defp deps do [ - {:ex_doc, "~> 0.27", only: :dev, runtime: false}, - {:excoveralls, "~> 0.10", only: :test}, {:jose, "~> 1.11"}, {:jason, "~> 1.4"}, - {:plug, "~> 1.14"}, - {:plug_cowboy, "~> 2.0"}, - {:httpoison, "~> 2.0"} + {:httpoison, "~> 2.0"}, + {:ex_doc, "~> 0.27", only: :dev, runtime: false}, + {:excoveralls, "~> 0.10", only: :test}, + {:plug, "~> 1.14", only: :test}, + {:plug_cowboy, "~> 2.0", only: :test} ] end end diff --git a/lib/web_push_elixir/mock_server.ex b/test/support/mock_server.ex similarity index 100% rename from lib/web_push_elixir/mock_server.ex rename to test/support/mock_server.ex diff --git a/test/test_helper.exs b/test/test_helper.exs index 4983c7c..2f08246 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,3 +1,6 @@ ExUnit.start() -DynamicSupervisor.start_child(WebPushElixir.DynamicSupervisor,{Plug.Cowboy, scheme: :http, plug: WebPushElixir.MockServer, options: [port: 4040]}) +DynamicSupervisor.start_child( + WebPushElixir.DynamicSupervisor, + {Plug.Cowboy, scheme: :http, plug: WebPushElixir.MockServer, options: [port: 4040]} +) diff --git a/test/web_push_elixir_test.exs b/test/web_push_elixir_test.exs index f4e0805..8c8b54d 100644 --- a/test/web_push_elixir_test.exs +++ b/test/web_push_elixir_test.exs @@ -1,7 +1,9 @@ defmodule WebPushElixirTest do use ExUnit.Case - @subscription '{"endpoint":"http://localhost:4040/some-push-service","keys":{"p256dh":"BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM=","auth":"tBHItJI5svbpez7KI4CCXg=="}}' + @subscription """ + {"endpoint":"http://localhost:4040/some-push-service","keys":{"p256dh":"BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM=","auth":"tBHItJI5svbpez7KI4CCXg=="}} + """ test "it should send notification" do %{