Integration tests for a Wagoe application: boot its own system on the test profile with in-process adapters, talk to it over Ring, and make the asynchronous parts deterministic (BOU-469).
(with-test-system [sys my-app.system-config/ig-config] (let [c (client sys)] (sign-in-as! c {:roles [:orders/editor]}) (request c :post "/web/orders" {:form {:sku "x"}}) (run-pending-jobs! sys) (drain-events! sys :orders)))
Lint the two macros as clojure.core/let; the jar exports that to
clj-kondo.
Integration tests for a Wagoe application: boot its own system on the test
profile with in-process adapters, talk to it over Ring, and make the
asynchronous parts deterministic (BOU-469).
(with-test-system [sys my-app.system-config/ig-config]
(let [c (client sys)]
(sign-in-as! c {:roles [:orders/editor]})
(request c :post "/web/orders" {:form {:sku "x"}})
(run-pending-jobs! sys)
(drain-events! sys :orders)))
Lint the two macros as `clojure.core/let`; the jar exports that to
clj-kondo.(call-with-tenant system input f)Create a tenant from input merged over a random slug and a name, call
(f tenant), then delete it and its schema.
Create a tenant from `input` merged over a random slug and a name, call (f tenant), then delete it and its schema.
(client system)(client system {:keys [headers]})A Ring client for system that keeps cookies and sends a valid CSRF token
with every state-changing request. headers go on every request, e.g.
{"x-tenant-slug" (:slug tenant)}.
A Ring client for `system` that keeps cookies and sends a valid CSRF token
with every state-changing request. `headers` go on every request, e.g.
{"x-tenant-slug" (:slug tenant)}.(create-user! system {:keys [roles] :as opts})Register a user and give them :roles through a group of their own.
Each role is a keyword, or {:role kw :scope map} to narrow it. Opts:
:roles, :email, :name, :password, :role (:admin for a platform admin).
Returns the user with its :password.
Register a user and give them `:roles` through a group of their own.
Each role is a keyword, or {:role kw :scope map} to narrow it. Opts:
:roles, :email, :name, :password, :role (`:admin` for a platform admin).
Returns the user with its :password.(drain-events! system topic)The events published to topic since the last drain, once every subscriber
has handled them.
The events published to `topic` since the last drain, once every subscriber has handled them.
(drain-realtime! system)The realtime envelopes sent since the last drain, oldest first: {:route :user|:role|:broadcast|:connection|:topic, :target …, :message …}.
The realtime envelopes sent since the last drain, oldest first:
{:route :user|:role|:broadcast|:connection|:topic, :target …, :message …}.(request c method uri)(request {:keys [handler headers cookies] :as c}
method
uri
{:keys [form json body query] :as opts})Send method uri through the app's handler and return the Ring response,
its body a string. Opts: :form (map, urlencoded), :json (data), :body
(string), :query (map), :headers.
Send `method` `uri` through the app's handler and return the Ring response, its body a string. Opts: :form (map, urlencoded), :json (data), :body (string), :query (map), :headers.
(run-pending-jobs! system)Run every due job on this thread, including jobs those jobs enqueue. Returns how many ran.
Run every due job on this thread, including jobs those jobs enqueue. Returns how many ran.
(sign-in! c email password)Sign in through the login form, as a browser does. The client keeps the session. Returns the response; throws when no session came back.
Sign in through the login form, as a browser does. The client keeps the session. Returns the response; throws when no session came back.
(sign-in-as! c opts)Create a user as create-user! does and sign c in as them. Returns the
user.
(sign-in-as! c {:roles [:orders/editor]})
Create a user as `create-user!` does and sign `c` in as them. Returns the
user.
(sign-in-as! c {:roles [:orders/editor]})(start-system ig-config-or-opts)Boot the application's Integrant system for a test and return it.
Takes the app's own (fn [config] ig-map), e.g.
my-app.system-config/ig-config, or a map:
:ig-config that function
:profile config profile to load (default :test)
:config (fn [config] config), applied before the in-process overrides
No HTTP port is bound; client calls the handler directly.
Boot the application's Integrant system for a test and return it. Takes the app's own (fn [config] ig-map), e.g. `my-app.system-config/ig-config`, or a map: :ig-config that function :profile config profile to load (default :test) :config (fn [config] config), applied before the in-process overrides No HTTP port is bound; `client` calls the handler directly.
(with-test-system [sym ig-config-or-opts] & body)Boot a test system from ig-config-or-opts (see start-system), bind it
to sym, run body, halt.
Boot a test system from `ig-config-or-opts` (see `start-system`), bind it to `sym`, run `body`, halt.
(with-test-tenant [sym system] & body)Run body with sym bound to a fresh tenant of system.
Run `body` with `sym` bound to a fresh tenant of `system`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |