Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Jun 29, 2023
1 parent 4fe5190 commit 167f513
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
23 changes: 23 additions & 0 deletions test/req/default_options_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule Req.DefaultOptionsTest do
use ExUnit.Case

setup do
bypass = Bypass.open()
[bypass: bypass, url: "http://localhost:#{bypass.port}"]
end

test "default options", c do
pid = self()

Bypass.expect(c.bypass, "GET", "/", fn conn ->
send(pid, {:params, conn.params})
Plug.Conn.send_resp(conn, 200, "ok")
end)

Req.default_options(params: %{"foo" => "bar"})
Req.get!(c.url)
assert_received {:params, %{"foo" => "bar"}}
after
Application.put_env(:req, :default_options, [])
end
end
2 changes: 1 addition & 1 deletion test/req/integration_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Req.IntegrationTest do
use ExUnit.Case
use ExUnit.Case, async: true

@moduletag :integration

Expand Down
15 changes: 0 additions & 15 deletions test/req_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ defmodule ReqTest do
[bypass: bypass, url: "http://localhost:#{bypass.port}"]
end

test "default options", c do
pid = self()

Bypass.expect(c.bypass, "GET", "/", fn conn ->
send(pid, {:params, conn.params})
Plug.Conn.send_resp(conn, 200, "ok")
end)

Req.default_options(params: %{"foo" => "bar"})
Req.get!(c.url)
assert_received {:params, %{"foo" => "bar"}}
after
Application.put_env(:req, :default_options, [])
end

test "default_headers", c do
Bypass.expect(c.bypass, "GET", "/", fn conn ->
[user_agent] = Plug.Conn.get_req_header(conn, "user-agent")
Expand Down

0 comments on commit 167f513

Please sign in to comment.