blob: e4151c21beefe640e1695012985f16ce6f3bae36 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
(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])
(: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 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))
|