Packages

A simple elixir library for ipify: A Simple IP Address API.

Current section

Files

Jump to
elixir_ipify test elixir_ipify_test.exs
Raw

test/elixir_ipify_test.exs

defmodule ElixirIpifyTest do
use ExUnit.Case
doctest ElixirIpify
test "test print_out function" do
assert ElixirIpify.print_out({:atom,"1.2.3.4"}) == "1.2.3.4"
end
test "handle_response function :ok" do
assert ElixirIpify.handle_response(
%{body: "1.2.3.4", status_code: 200}) == {:ok, "1.2.3.4"}
end
test "handle_response function :error" do
assert ElixirIpify.handle_response(
%{message: ""}) == {:error, "Nothing goes wrong!"}
end
test "fetch function success" do
ip = System.cmd "curl", ["-s", "https://api.ipify.org"]
assert ElixirIpify.fetch == elem(ip,0)
end
test "fetch function failed" do
assert ElixirIpify.fetch("host.local") ==
"Nothing goes wrong!"
end
end