From 1248eeb88d90f0ece972299d40b7406ef0a17cf5 Mon Sep 17 00:00:00 2001 From: kballou Date: Thu, 28 Jul 2016 16:44:32 -0600 Subject: Add HTTP "Ping" --- test/http_test.exs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/http_test.exs (limited to 'test/http_test.exs') diff --git a/test/http_test.exs b/test/http_test.exs new file mode 100644 index 0000000..61847d4 --- /dev/null +++ b/test/http_test.exs @@ -0,0 +1,36 @@ +defmodule ExPing.HTTP.Test do + use ExUnit.Case + + describe "head requests" do + test "can get ok response" do + for code <- [200, 405] do + {:ok, _} = ExPing.HTTP.head(URI.parse("localhost/#{code}")) + end + end + + test "can get error response" do + {:error, _} = ExPing.HTTP.head(URI.parse("localhost/500")) + end + + test "can get timeout response" do + {:error, :timeout} = ExPing.HTTP.head(URI.parse("localhost/timeout")) + end + end + + describe "get requests" do + test "can get ok response" do + for code <- [200, 400, 404] do + {:ok, _} = ExPing.HTTP.get(URI.parse("localhost/#{code}")) + end + end + + test "can get error response" do + {:error, _} = ExPing.HTTP.get(URI.parse("localhost/500")) + end + + test "can get timeout response" do + {:error, :timeout} = ExPing.HTTP.get(URI.parse("localhost/timeout")) + end + end + +end -- cgit v1.2.1