View Source TestServer (TestServer v0.1.3)
No fuzz ExUnit test server to mock third party services.
Features:
- HTTP/1
- HTTP/2
- Built-in TLS with self-signed certificates
- Plug route matching
Link to this section Summary
Functions
Adds a route to the current test server.
Adds a route to a test server instance.
Gets current test server instance if running.
Adds a plug to the current test server.
Adds a route to a test server instance.
Start a test server instance.
Shuts down the current test server.
Shuts down a test server instance.
Produces a URL for current test server.
Produces a URL for a test server instance.
Fetches the generated x509 suite for the current test server.
Fetches the generated x509 suite for a test server instance.
Link to this section Functions
@spec add( binary(), keyword() ) :: :ok | {:error, term()}
@spec add(pid(), binary()) :: :ok | {:error, term()}
Adds a route to the current test server.
options
Options
:via
- matches the route against some specific HTTP method(s) specified as an atom, like:get
or:put
, or a list, like[:get, :post]
.:match
- an anonymous function that will be called to see if a route matches, defaults to matching with arguments of uri and:via
option.:to
- a Plug or anonymous function that will be called when the route matches.
Adds a route to a test server instance.
See add/2
for options.
@spec get_instance() :: pid() | nil
Gets current test server instance if running.
Adds a plug to the current test server.
This plug will be called for all requests before route is matched.
Adds a route to a test server instance.
See plug/1
for options.
Start a test server instance.
The instance will be terminated when the test case finishes.
options
Options
:port
- integer of port number, defaults to random port that can be opened;:scheme
- an atom for the http scheme. Defaults to:http
;:cowboy_options
- See Cowboy docs
@spec stop() :: :ok | {:error, term()}
Shuts down the current test server.
Shuts down a test server instance.
@spec url() :: binary()
Produces a URL for current test server.
options
Options
:host
- binary host value, it'll be added to inet for IP 127.0.0.1, defaults to"localhost"
;
Produces a URL for a test server instance.
See url/2
for options.
@spec x509_suite() :: term()
Fetches the generated x509 suite for the current test server.
Fetches the generated x509 suite for a test server instance.