Skip to content

Commit

Permalink
update conn & adapter test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Dec 18, 2016
1 parent e3e0b3b commit ad800c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/maxwell/adapter/adapter_test.exs
Expand Up @@ -27,6 +27,12 @@ defmodule MaxwellAdapterTest do
assert result |> Conn.get_status == 200
end

test "test :query string" do
{:ok, result} = %{"name" => "china"} |> Conn.put_query_string |> Client.get
assert result.query_string == %{"name" => "china"}
assert result |> Conn.get_status == 200
end

test "return :status 400" do
assert_raise(Maxwell.Error, "url: \npath: \"\"\nmethod: get\nstatus: 400\nreason: :response_status_not_match\nmodule: Elixir.MaxwellAdapterTest.Client\n",
fn() -> %Conn{status: 100} |> Client.get! end)
Expand Down
7 changes: 7 additions & 0 deletions test/maxwell/conn_test.exs
Expand Up @@ -87,6 +87,13 @@ defmodule ConnTest do
end
end

test "get_req_header/2 get_req_header/3 test" do
assert get_req_header(%Conn{req_headers: %{"server" => {"Server", "Microsoft-IIS/8.5"}}})
== %{"Server" => "Microsoft-IIS/8.5"}
assert get_req_header(%Conn{resp_headers: %{"server" => {"Server", "Microsoft-IIS/8.5"}}}, "Server")
== {"Server", "Microsoft-IIS/8.5"}
end

test "get_resp_body/2 get_resp_body/3 test" do
assert get_resp_body(%Conn{state: :sent, resp_body: "I'm ok"}) == "I'm ok"
assert get_resp_body(%Conn{state: :sent, resp_body: %{"foo" => %{"addr" => "China"}}}, ["foo", "addr"]) == "China"
Expand Down

0 comments on commit ad800c2

Please sign in to comment.