Skip to content

Commit

Permalink
Adds test for receiving cookies from a get request
Browse files Browse the repository at this point in the history
  • Loading branch information
lilactown committed Jan 26, 2017
1 parent e9b5725 commit a3da6a9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/httpoison_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ defmodule HTTPoisonTest do
assert response.body |> String.replace( ~r/\s|\r?\n/, "") |> String.replace(~r/\"/, "'") |> JSX.decode! == %{"cookies" => %{"foo" => "1", "bar" => "2"}}
end

test "receive cookies" do
response = HTTPoison.get!("localhost:8080/cookies/set?foo=1&bar=2")
has_foo = Enum.member?(response.headers, {"set-cookie", "foo=1; Version=1; Path=/"})
has_bar = Enum.member?(response.headers, {"set-cookie", "bar=2; Version=1; Path=/"})
assert has_foo and has_bar
end

test "exception" do
assert HTTPoison.get "localhost:1" == {:error, %HTTPoison.Error{reason: :econnrefused}}
assert_raise HTTPoison.Error, ":econnrefused", fn ->
Expand Down

0 comments on commit a3da6a9

Please sign in to comment.