forked from sneako/finch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinch_request_test.exs
34 lines (29 loc) · 1.06 KB
/
finch_request_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
defmodule Finch.RequestTest do
use ExUnit.Case, async: true
describe "put_private/3" do
test "accepts atoms as keys" do
request =
Finch.build(:get, "http://example.com")
|> Finch.Request.put_private(:my_lib_key, :foo)
assert request.private == %{my_lib_key: :foo}
end
test "appends to the map when called multiple times" do
request =
Finch.build(:get, "http://example.com")
|> Finch.Request.put_private(:my_lib_key, :foo)
|> Finch.Request.put_private(:my_lib_key2, :bar)
assert request.private == %{my_lib_key: :foo, my_lib_key2: :bar}
end
test "raises when invalid key is used" do
assert_raise ArgumentError,
"""
got unsupported private metadata key "my_key"
only atoms are allowed as keys of the `:private` field.
""",
fn ->
Finch.build(:get, "http://example.com")
|> Finch.Request.put_private("my_key", :foo)
end
end
end
end