You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code executes normally and successfully in dev, but when running mix test, the test is failing the majority of the time. It sometimes succeeds, which is utterly baffling.
defmodule Geeks.LocationTest do
use ExUnit.Case, async: false
test "gets a geopoint for an ip" do
ip = {161,185,160,93}
actual = Geeks.Location.get_ip(ip)
{:ok, %{ coordinates: [lon, lat], srid: "4326"}} = actual
assert [-73.9501, 40.781] = [ lon, lat ]
end
end
Code under test:
def get_ip(ip) do
ip_string = Tuple.to_list(ip) |> Enum.join(".")
case Geolix.lookup(ip_string, where: :city) do
%{ location: %{ latitude: lat, longitude: lon }} -> {:ok, %Geo.Point{ coordinates: [lon, lat], srid: "4326"}}
_ -> {:error, "location not found for ip #{ip_string}"}
end
end
I switched the adapter to a Fake adapter in test, and it's working like a boss. Kind of a bummer I couldn't get a more thorough test, but this will get me through the build cycle, thank you so much for providing it!
The code executes normally and successfully in dev, but when running mix test, the test is failing the majority of the time. It sometimes succeeds, which is utterly baffling.
config.exs
Failing test:
Code under test:
mix.lock
Here's the successful execution in iex:
The text was updated successfully, but these errors were encountered: