Skip to content

Commit

Permalink
attempt to fix tests on OTP 22
Browse files Browse the repository at this point in the history
  • Loading branch information
asakura committed Nov 17, 2023
1 parent 4a66d92 commit 77c5f64
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/http_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
{
Expand All @@ -25,16 +33,15 @@ 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

test "post/4" do
response =
NoOp.post(
"https://localhost:40010/post_endpoint",
"#{@base_url}/post_endpoint",
"body",
[
{"Content-Type", "application/x-www-form-urlencoded"}
Expand All @@ -49,7 +56,7 @@ defmodule MixpanelTest.HTTPTest do
describe "HTTP adapters" do
for adapter <- [Hackney, HTTPC] do
test "#{adapter}.get/3" do

Check failure on line 58 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.12|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.Hackney.get/3 (MixpanelTest.HTTPTest)

Check failure on line 58 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.12|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.HTTPC.get/3 (MixpanelTest.HTTPTest)

Check failure on line 58 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.13|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.HTTPC.get/3 (MixpanelTest.HTTPTest)

Check failure on line 58 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.13|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.Hackney.get/3 (MixpanelTest.HTTPTest)
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)
~> %{
Expand All @@ -71,7 +78,7 @@ defmodule MixpanelTest.HTTPTest do

test "#{adapter}.post/4" do

Check failure on line 79 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.12|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.HTTPC.post/4 (MixpanelTest.HTTPTest)

Check failure on line 79 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.12|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.Hackney.post/4 (MixpanelTest.HTTPTest)

Check failure on line 79 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.13|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.Hackney.post/4 (MixpanelTest.HTTPTest)

Check failure on line 79 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / test|OTP 22|Elixir 1.13|ubuntu-20.04

test HTTP adapters Elixir.Mixpanel.HTTP.HTTPC.post/4 (MixpanelTest.HTTPTest)
case unquote(adapter).post(
"https://localhost:40010/post_endpoint",
"#{@base_url}/post_endpoint",
"body",
[
{"Content-Type", "application/x-www-form-urlencoded"}
Expand Down

0 comments on commit 77c5f64

Please sign in to comment.