1
0
Fork 0
mirror of https://github.com/edgurgel/httparrot synced 2025-04-05 16:22:32 -04:00
httparrot/test/store_request_handler_test.exs
2019-06-29 14:41:16 +03:00

26 lines
896 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) == {'{"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) == {'{"saved": "true"}', :req1, :state}
assert get(:req2, :state) == {'{"saved": "true"}', :req1, :state}
assert HTTParrot.RequestStore.retrieve(:test) == [:info, :info]
end
end