io.pedestal.test
Pedestal testing utilities; mock implementations of the core Servlet API objects, to support fast integration testing without starting a servlet container, or opening a port for HTTP traffic.
create-responder
added in 0.8.0
(create-responder service-map)
Given a service map, this returns a function that wraps response-for.
The returned function’s signature is: verb url & options
disable-routing-table-output-fixture
added in 0.7.0
(disable-routing-table-output-fixture f)
A test fixture that disables printing of the routing table, even when development mode is enabled. It also disables ANSI colors in any Pedestal console output (such as deprecation warnings).
raw-response-for
(raw-response-for interceptor-service-fn verb url & options)
Return a Ring response map for an HTTP request of type verb
against url url
, when applied to interceptor-service-fn. Useful for integration testing pedestal applications and getting all relevant middlewares invoked, including ones which integrate with the servlet infrastructure. The response body will be returned as a ByteArrayOutputStream.
Note that the Content-Length
header, if present, will be a number, not a string.
Options: :body : An optional string that is the request body. :headers : An optional map that are the headers
response-for
(response-for interceptor-service-fn verb url & options)
Return a Ring response map for an HTTP request of type verb
against url url
, when applied to interceptor-service-fn. Useful for integration testing pedestal applications and getting all relevant middlewares invoked, including ones which integrate with the servlet infrastructure. The response body will be converted to a UTF-8 string.
This builds on raw-response-for, see a note there about headers.
An empty response body will be returned as an empty string.
Options:
:body : An optional string that is the request body. :headers : An optional map that are the headers
servlet-response-for
(servlet-response-for interceptor-service-fn verb url & args)
Return a Ring response map for an HTTP request of type verb
against url url
, when applied to interceptor-service-fn. Useful for integration testing pedestal applications and getting all relevant middlewares invoked, including ones which integrate with the servlet infrastructure.
test-servlet-response
(test-servlet-response)
Returns a mock servlet response with a ServletOutputStream over a ByteArrayOutputStream. Captures the ByteArrayOutputStream in metadata. All headers set will swap a headers map held in an atom, also held in metadata.