aboutsummaryrefslogtreecommitdiff
path: root/test/http_test.exs
diff options
context:
space:
mode:
authorkballou <kballou@devnulllabs.io>2016-07-28 16:44:32 -0600
committerkballou <kballou@devnulllabs.io>2016-07-29 11:36:04 -0600
commit1248eeb88d90f0ece972299d40b7406ef0a17cf5 (patch)
tree813c9c8c899a5752409641e47c4480f5e0308721 /test/http_test.exs
parent2175a2f4d9a416f4a443166a2487c8c12a3df9e2 (diff)
downloadexping-1248eeb88d90f0ece972299d40b7406ef0a17cf5.tar.gz
exping-1248eeb88d90f0ece972299d40b7406ef0a17cf5.tar.xz
Add HTTP "Ping"
Diffstat (limited to 'test/http_test.exs')
-rw-r--r--test/http_test.exs36
1 files changed, 36 insertions, 0 deletions
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