Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
darkleaf committed Oct 22, 2024
1 parent 51cfc81 commit ab8501e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/darkleaf/di/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
(p/dependencies factory))
(build [_ deps]
(let [obj (p/build factory deps)]
(built-cb key deps obj)
(built-cb key obj)
obj))
(demolish [_ obj]
(p/demolish factory obj)
Expand Down
31 changes: 14 additions & 17 deletions test/darkleaf/di/tutorial/x_log_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@
:c)

(t/deftest log
(let [logs (atom [])
built! (fn [key deps obj]
(swap! logs conj [:built key deps obj]))
demolished! (fn [key obj]
(swap! logs conj [:demolished key obj]))
[a b c
:as system] (di/start [`a `b `c]
(di/log built! demolished!))]
(di/stop system)
(t/is (= [[:built `a {} a]
[:built `b {`a a} b]
[:built `c {`b b} c]
[:built ::di/implicit-root {`a a `b b `c c} [a b c]]
[:demolished ::di/implicit-root [a b c]]
[:demolished `c c]
[:demolished `b b]
[:demolished `a a]]
(let [logs (atom [])
built! (fn [key obj]
(swap! logs conj [:built key (pr-str obj)]))
demolished! (fn [key obj]
(swap! logs conj [:demolished key (pr-str obj)]))]
(with-open [root (di/start `c (di/log built! demolished!))])
(t/is (= [[:built `a ":a"]
[:built `b
"#darkleaf.di.core/service #'darkleaf.di.tutorial.x-log-test/b"]
[:built `c ":c"]
[:demolished `c ":c"]
[:demolished `b
"#darkleaf.di.core/service #'darkleaf.di.tutorial.x-log-test/b"]
[:demolished `a ":a"]]
@logs))))

0 comments on commit ab8501e

Please sign in to comment.