diff --git a/test/http_test.exs b/test/http_test.exs index b9e58a6..b5d9f71 100644 --- a/test/http_test.exs +++ b/test/http_test.exs @@ -4,6 +4,14 @@ defmodule MixpanelTest.HTTPTest do alias Mixpanel.HTTP.{Hackney, HTTPC, NoOp} + # Erlang 22 comparability layer + # Remove it when OTP 22 support is dropped + @base_url if(:erlang.system_info(:otp_release) |> to_string() == "22") do + "localhost:40010" + else + "https://localhost:40010" + end + setup_all do child = { @@ -25,8 +33,7 @@ defmodule MixpanelTest.HTTPTest do describe "NoOp adapter" do test "get/3" do - response = - NoOp.get("https://localhost:40010/get_endpoint", [], insecure: true) + response = NoOp.get("#{base_url}/get_endpoint", [], insecure: true) assert response == {:ok, 200, [], "1"} end @@ -34,7 +41,7 @@ defmodule MixpanelTest.HTTPTest do test "post/4" do response = NoOp.post( - "https://localhost:40010/post_endpoint", + "#{base_url}/post_endpoint", "body", [ {"Content-Type", "application/x-www-form-urlencoded"} @@ -49,7 +56,7 @@ defmodule MixpanelTest.HTTPTest do describe "HTTP adapters" do for adapter <- [Hackney, HTTPC] do test "#{adapter}.get/3" do - case unquote(adapter).get("https://localhost:40010/get_endpoint", [], insecure: true) do + case unquote(adapter).get("#{base_url}/get_endpoint", [], insecure: true) do {:ok, 200, _headers, body} -> assert Jason.decode!(body) ~> %{ @@ -71,7 +78,7 @@ defmodule MixpanelTest.HTTPTest do test "#{adapter}.post/4" do case unquote(adapter).post( - "https://localhost:40010/post_endpoint", + "#{base_url}/post_endpoint", "body", [ {"Content-Type", "application/x-www-form-urlencoded"}