-
Notifications
You must be signed in to change notification settings - Fork 0
/
t_connector.clj
54 lines (43 loc) · 1.84 KB
/
t_connector.clj
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
(ns persistroids.t-connector
(:require [midje.sweet :refer :all]
[taoensso.timbre :as logger]
[persistroids.core :as p]
[persistroids.connector :as connector]))
(background
(around :facts
(logger/with-level :info ?form)))
;an exploration of the persistroids/connector relationship
(declare verify-connector-read)
(declare verify-connector-write)
(declare verify-connector-flush)
(midje.config/at-print-level
:print-facts
(facts
"an exploration of the persistroids/connector relationship"
(let [my-connector (reify connector/Connector
(get-id [this] "my-connector")
(read [this args]
(verify-connector-read args))
(write [this args value]
(verify-connector-write args value))
(flush [this writes]
(verify-connector-flush (into [] writes))))
persistroids (p/init :connectors [my-connector])]
(fact
"read relationship"
(p/read persistroids ..my-args..) => ..my-value..
(provided (verify-connector-read ..my-args..) => ..my-value..))
(fact
"write relationship"
(p/write persistroids ..my-args.. ..my-value..) => ..my-value..
(provided (verify-connector-write ..my-args.. ..my-value..) => ..my-write-result..))
(fact
"write relationship, no buffering"
(p/write persistroids ..other-args.. ..my-value..) => ..my-value..
(provided (verify-connector-write ..other-args.. ..my-value..) => nil))
(fact
"flush relationship"
(p/flush-now persistroids) => nil
(provided (verify-connector-flush [..my-write-result..]) => nil))
(p/shutdown persistroids)))
)