Back

run! (clj)

(source)

function

(run! system keys f)
Apply a side-effectful function f to each key value pair in a system map. Keys are traversed in dependency order. The function should take two arguments, a key and value.

Examples

integrant
(ns integrant.core-test
  (:require #?(:clj  [clojure.test :refer [are deftest is testing]]
               :cljs [cljs.test :refer-macros [are deftest is testing]])
            [integrant.core :as ig]
            [weavejester.dependency :as dep]))

(deftest run-test
  (let [config {::a (ig/ref ::b), ::b 1}
        [system _] (build-log config)]
    (is (= [nil
            [[:test ::b [:build ::b 1]]
             [:test ::a [:build ::a [:build ::b 1]]]]]
           (test-log ig/run! system)))
    (is (= [nil
            [[:test ::a [:build ::a [:build ::b 1]]]
             [:test ::b [:build ::b 1]]]]
           (test-log ig/reverse-run! system)))))
samply/blaze
(ns blaze.db.test-util
  (:require
   [blaze.db.api :as d]
   [blaze.db.kv :as kv]
   [blaze.db.kv.mem]
   [blaze.db.node]
   [blaze.db.resource-store :as rs]
   [blaze.db.resource-store.kv :as rs-kv]
   [blaze.db.tx-cache]
   [blaze.db.tx-log :as tx-log]
   [blaze.db.tx-log.local]
   [blaze.fhir.test-util :refer [structure-definition-repo]]
   [blaze.module.test-util :refer [with-system]]
   [integrant.core :as ig]
   [java-time.api :as time]))

  Additionally the database is initialized with `txs`."
  [[binding-form config] txs & body]
  `(with-system [system# ~config]
     (run! #(deref (d/transact (:blaze.db/node system#) %)) ~txs)
     (let [~binding-form system#] ~@body)))