diff options
| author | EuAndreh <eu@euandre.org> | 2025-12-05 19:57:57 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2025-12-05 19:57:57 -0300 |
| commit | e1b99db2364971d456a62e8ec7567e6b5250d004 (patch) | |
| tree | 8b1b7772cc44d90b97856d5d02481f3649e65908 /test/com/github/ivarref/yoltq/test_utils.clj | |
| parent | rm -rf *: setup change to Clojure (diff) | |
| parent | Update for release (diff) | |
| download | fiinha-e1b99db2364971d456a62e8ec7567e6b5250d004.tar.gz fiinha-e1b99db2364971d456a62e8ec7567e6b5250d004.tar.xz | |
Merge remote-tracking branch 'upstream/main', where "upstream" is yoltq.
Diffstat (limited to 'test/com/github/ivarref/yoltq/test_utils.clj')
| -rw-r--r-- | test/com/github/ivarref/yoltq/test_utils.clj | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/test/com/github/ivarref/yoltq/test_utils.clj b/test/com/github/ivarref/yoltq/test_utils.clj new file mode 100644 index 0000000..0c1b2f0 --- /dev/null +++ b/test/com/github/ivarref/yoltq/test_utils.clj @@ -0,0 +1,80 @@ +(ns com.github.ivarref.yoltq.test-utils + (:require [com.github.ivarref.yoltq.log-init :as logconfig] + [clojure.tools.logging :as log] + [com.github.ivarref.yoltq.utils :as u] + [com.github.ivarref.yoltq :as yq] + [datomic.api :as d] + [clojure.string :as str] + [com.github.ivarref.yoltq.impl :as i] + [clojure.edn :as edn] + [com.github.ivarref.yoltq.ext-sys :as ext] + [clojure.pprint :as pp]) + (:import (java.util UUID) + (java.time Duration))) + + +(logconfig/init-logging! + [[#{"datomic.*" "com.datomic.*" "org.apache.*"} :warn] + [#{"*"} (edn/read-string + (System/getProperty "TAOENSSO_TIMBRE_MIN_LEVEL_EDN" ":info"))]]) + + +(defn empty-conn [] + (let [uri (str "datomic:mem://hello-world-" (UUID/randomUUID))] + (d/delete-database uri) + (d/create-database uri) + (d/connect uri))) + + +(defn break [] + (log/info (str/join "*" (repeat 60 "")))) + + +(defn clear [] + (.print System/out "\033[H\033[2J") + (.flush System/out) + (break)) + + +(defn put-transact! [id payload] + @(d/transact (:conn @yq/*config*) [(i/put @yq/*config* id payload {})])) + + +(defn advance! [tp] + (assert (some? ext/*now-ms-atom*) "Expected to be running in test-mode!") + (swap! ext/*now-ms-atom* + (if (number? tp) + tp + (.toMillis ^Duration tp)))) + + +(defn done-count [] + (d/q '[:find (count ?e) . + :where + [?e :com.github.ivarref.yoltq/id _] + [?e :com.github.ivarref.yoltq/status :done]] + (d/db (:conn @yq/*config*)))) + + +(defn pp [x] + (pp/pprint x) + x) + +(defn get-init [& args] + (apply u/get-init @yq/*config* args)) + + +(defn get-error [& args] + (apply u/get-error @yq/*config* args)) + + +(defn get-hung [& args] + (apply u/get-hung @yq/*config* args)) + + +(defn take! [& args] + (apply i/take! @yq/*config* args)) + + +(defn execute! [& args] + (apply i/execute! @yq/*config* args)) + |
