Packages
eview
0.5.2
0.16.0
retired
0.15.0
0.14.0
0.13.0
0.12.5
0.12.4
0.12.3
0.12.2
0.12.1
0.12.0
0.11.1
0.11.0
0.10.8
0.10.7
0.10.6
0.10.5
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.7
0.9.6
0.9.5
0.9.4
0.9.3
0.9.2
0.9.0
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.0
0.3.0
0.2.9
0.2.7
0.2.6
0.2.5
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0
Plug that converts response to Nebo #15 API spec format.
Current section
Files
Jump to
Current section
Files
lib/eview/test/acceptance_case.ex
defmodule EView.AcceptanceCase do
@moduledoc """
This module defines the test case to be used by
acceptance tests. It can allow run tests in async when each SQL.Sandbox connection will be
binded to a specific test.
"""
use ExUnit.CaseTemplate
using(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
unless opts[:otp_app] do
throw "You need to specify `otp_app` when using AcceptanceCase."
end
unless opts[:endpoint] do
throw "You need to specify `endpoint` when using AcceptanceCase."
end
# Configure acceptance testing on different host:port
conf = Application.get_env(opts[:otp_app], opts[:endpoint])
host = System.get_env("CONTAINER_HTTP_HOST") || conf[:http][:host] || "localhost"
port = System.get_env("CONTAINER_HTTP_PORT") || conf[:http][:port]
@http_uri "http://#{host}:#{port}/"
@repo opts[:repo]
@endpoint opts[:endpoint]
@headers opts[:headers] || []
use HTTPoison.Base
import Ecto.Query, only: [from: 2]
import EView.AcceptanceCase
# if opts[:repo] do
# alias @repo
# end
def process_url(url) do
@http_uri <> url
end
if is_atom(opts[:repo]) and not is_nil(opts[:repo]) and opts[:async] do
defp process_request_headers(headers) do
meta = Phoenix.Ecto.SQL.Sandbox.metadata_for(@repo, self())
encoded = {:v1, meta}
|> :erlang.term_to_binary
|> Base.url_encode64
[{"content-type", "application/json"},
{"user-agent", "BeamMetadata (#{encoded})"}] ++ @headers ++ headers
end
else
defp process_request_headers(headers) do
[{"content-type", "application/json"}] ++ @headers ++ headers
end
end
defp process_request_body(body) do
body
|> Poison.encode!
end
defp process_response_body(body) do
body
|> Poison.decode!
end
if is_atom(opts[:repo]) and not is_nil(opts[:repo]) do
setup tags do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(@repo)
unless tags[:async] do
Ecto.Adapters.SQL.Sandbox.mode(@repo, {:shared, self()})
end
:ok
end
end
end
end
def get_body(map) do
map
|> Map.get(:body)
end
end