Skip to content

Commit

Permalink
wip3
Browse files Browse the repository at this point in the history
  • Loading branch information
darkleaf committed Oct 23, 2024
1 parent 01af1b8 commit 4ec3b4e
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions test/darkleaf/di/dependencies_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@
;; c

(defn root
{::di/stop #(swap! % conj [`root :stopped])}
[{a `a, b `b, log ::log}]
(swap! log conj [`root :built])
log)
{::di/kind :component}
[{a `a, b `b}]
:root)

(defn a
{::di/stop #(swap! % conj [`a :stopped])}
[{c `c, log ::log}]
(swap! log conj [`a :built])
log)
{::di/kind :component}
[{c `c}]
:a)

(defn b
{::di/stop #(swap! % conj [`b :stopped])}
[{c `c, log ::log}]
(swap! log conj [`b :built])
log)
{::di/kind :component}
[{c `c}]
:b)

(defn c
{::di/stop #(swap! % conj [`c :stopped])}
[{log ::log}]
(swap! log conj [`c :built])
log)
{::di/kind :component}
[]
:c)

(t/deftest order-test
(let [log (atom [])]
(-> (di/start `root {::log log})
(di/stop))
(let [log (atom [])
built! (fn [key obj]
(swap! log conj [key :built]))
demolish! (fn [key obj]
(swap! log conj [key :stopped]))]
(with-open [root (di/start `root (di/log built! demolish!))])
(t/is (= [[`c :built]
[`a :built]
[`b :built]
Expand Down

0 comments on commit 4ec3b4e

Please sign in to comment.