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 ba28d17
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

Check warning on line 9 in test/http_test.exs

View workflow job for this annotation

GitHub Actions / lint|OTP 26|Elixir 1.15|ubuntu-22.04

The condition of `if` should not be wrapped in parentheses.
"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
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
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 ba28d17

Please sign in to comment.