1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-05 00:02:41 -04:00
httparrot/test/store_request_handler_test.exs
2024-06-25 21:23:13 +12:00

26 lines
902 B
Elixir

defmodule HTTParrot.StoreRequestHandlerTests do
use ExUnit.Case
import :meck
import HTTParrot.StoreRequestHandler
setup do
HTTParrot.RequestStore.clear(:test)
on_exit(fn -> unload() end)
:ok
end
test "store a request" do
expect(:cowboy_req, :binding, [:key, :req1], :test)
expect(HTTParrot.GeneralRequestInfo, :retrieve, 1, {:info, :req1})
assert get(:req1, :state) == {~c'{"saved": "true"}', :req1, :state}
assert HTTParrot.RequestStore.retrieve(:test) == [:info]
end
test "store multiple requests" do
expect(:cowboy_req, :binding, [:key, :req1], :test)
expect(HTTParrot.GeneralRequestInfo, :retrieve, 1, {:info, :req1})
assert get(:req1, :state) == {~c'{"saved": "true"}', :req1, :state}
assert get(:req2, :state) == {~c'{"saved": "true"}', :req1, :state}
assert HTTParrot.RequestStore.retrieve(:test) == [:info, :info]
end
end