Includes:
read-body
multimethod for parsing response bodies of different types (transit, json etc)Includes: * Macros and a fixture for dealing with a system for the duration of a test * Helpers for composing and dispatching requests * `read-body` multimethod for parsing response bodies of different types (transit, json etc) * assertions that work with response segments
(comparison-entities test-ent-attrs resp-data)
Returns a set that can be used to test if test-ent-attrs
is
contained in a response
Returns a set that can be used to test if `test-ent-attrs` is contained in a response
(configured-value config-key)
Look up a component instance that has path configured by the ::config
component group
Look up a component instance that has path configured by the `::config` component group
(contains-entity? resp-data test-ent-attrs)
Request's response data has a map with key/value pairs identical to
test-ent-attrs
.
Request's response data has a map with key/value pairs identical to `test-ent-attrs`.
Multi method that sets headers and encodes body for a content type
Multi method that sets headers and encodes body for a content type
(handle-request {:keys [path route-name route-params body-params query-params
content-type]
:as req-map})
(handle-request method
path-or-route-name
&
[route-params body-params query-params])
Perform a request with the system's ring handler
Perform a request with the system's ring handler
(handler)
Retrieve endpoint handler from ds/system. Relies on :donut/http-handler
being set in the system's ::ds/registry
Retrieve endpoint handler from ds/*system*. Relies on `:donut/http-handler` being set in the system's `::ds/registry`
(prep-comparison resp-entity test-ent-attrs)
When testing whether a response contains test-ent-attrs
, we modify
a response entity by:
selecting only the keys that are present in
test-ent-attrs
. This allows us to do an =
comparison that won't
fail if the response entity contains attributes we don't want to
test.
Putting the result in a map to handle case where resp-entity
is
a record.
When testing whether a response contains `test-ent-attrs`, we modify a response entity by: 1. selecting only the keys that are present in `test-ent-attrs`. This allows us to do an `=` comparison that won't fail if the response entity contains attributes we don't want to test. 2. Putting the result in a map to handle case where `resp-entity` is a record.
Decodes a response body, transforming it from JSON or whatever back into Clojure, which we love
Decodes a response body, transforming it from JSON or whatever back into Clojure, which we love
(request {:keys [path route-name route-params query-params content-type]
:as req-map})
(request method path-or-route-name & [route-params body-params query-params])
Construct a ring.mock.request/request using your ds/system router to build a path. Adds content-type and accept headers.
Single-arity version takes a map with:
:method HTTP method
:path string; use if you don't want to use router to build path
:route-name used to build path :route-params map to populate your route's params, e.g. :book/id in /api/books {book/id} :query-params map to add a query string :body-params the data for your request
Construct a ring.mock.request/request using your ds/*system* router to build a path. Adds content-type and accept headers. Single-arity version takes a map with: :method HTTP method :path string; use if you don't want to use router to build path :route-name used to build path :route-params map to populate your route's params, e.g. :book/id in /api/books {book/id} :query-params map to add a query string :body-params the data for your request
(response {:keys [path route-name route-params body-params query-params
content-type]
:as req-map})
(response method path-or-route-name & [route-params body-params query-params])
Comp of handle-request and read-body; handles a request and reads the body.
Comp of handle-request and read-body; handles a request and reads the body.
(response-entities resp-data)
Walk response data and return all entities from entity segments
Walk response data and return all entities from entity segments
(route-path route-name)
(route-path route-name route-params)
(route-path route-name route-params query-params)
Construct a path like /api/v1/books/1. Can also build query string.
Construct a path like /api/v1/books/1. Can also build query string.
(router)
Retrieve endpoint router from ds/system. Relies on :donut/endpoint-router
being set in the system's ::ds/registry
Retrieve endpoint router from ds/*system*. Relies on `:donut/endpoint-router` being set in the system's `::ds/registry`
(system)
Get ds/system and throw when it's not set. Used by other helpers. Intention is to reduce the boilerplate of system retrieval in your tests.
Get ds/*system* and throw when it's not set. Used by other helpers. Intention is to reduce the boilerplate of system retrieval in your tests.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close