diff --git a/src/darkleaf/di/core.clj b/src/darkleaf/di/core.clj index 08641eb..01510a4 100644 --- a/src/darkleaf/di/core.clj +++ b/src/darkleaf/di/core.clj @@ -528,11 +528,11 @@ args (map deps arg-keys)] (apply f t args))) (demolish [_ _]) - p/FactoryDescription (description [_] - {::middleware ::update-key - ::target target})) + {:kind :middleware + :middleware ::update-key + :target target})) own-registry (zipmap (cons f-key arg-keys) (cons f args)) target-factory (registry target)] @@ -630,7 +630,18 @@ (demolish [_ _]))) (defn- var->0-service [variable] - variable) + ;; todo: meta ::service + + (reify + p/Factory + (dependencies [_]) + (build [_ _] + variable) + (demolish [_ _]) + p/FactoryDescription + (description [_] + {:kind :service + :var variable}))) (defn- var->service [variable] (let [deps (dependencies-fn variable)] @@ -849,8 +860,8 @@ info (into {} (filter (fn [[k v]] (some? v))) {:key key - :dependencies declared-deps - :meta (p/description factory)})] + :dependencies (not-empty declared-deps) + :description (not-empty (p/description factory))})] (reify p/Factory (dependencies [_] declared-deps) diff --git a/test/darkleaf/di/tutorial/x_inspect_test.clj b/test/darkleaf/di/tutorial/x_inspect_test.clj index 9ce9922..c3d342b 100644 --- a/test/darkleaf/di/tutorial/x_inspect_test.clj +++ b/test/darkleaf/di/tutorial/x_inspect_test.clj @@ -14,31 +14,41 @@ :or {b :default}}] :ok) + +(t/deftest zero-arity-service-test + (t/is (= [{:key ::di/implicit-root + :dependencies {`a :required}} + {:key `a + :description {:kind :service + :var #'a}}] + (di/inspect `a)))) + + +;; todo: name (t/deftest ok (t/is (= [{:key ::di/implicit-root - :dependencies {`c :required} - :meta {}} + :dependencies {`c :required}} {:key `c - :dependencies {`a :required `b :optional} - :meta {}} - {:key `a - :meta {}} + :dependencies {`a :required `b :optional}} + {:key `a + :description {:kind :service + :var #'a}} {:key `b - :dependencies {`a :required} - :meta {}}] + :dependencies {`a :required}}] (di/inspect `c)))) -(t/deftest meta-test + +(t/deftest update-key-test (t/is (= [{:key ::di/implicit-root, - :dependencies {`a :required} - :meta {}} + :dependencies {`a :required}} {:key `a, :dependencies {`a+di-update-key#0-target :optional, `a+di-update-key#0-f :optional} - :meta {::di/middleware ::di/update-key - ::di/target `a}} - {:key `a+di-update-key#0-target - :meta {}} - {:key `a+di-update-key#0-f - :meta {}}] + :description {:kind :middleware + :middleware ::di/update-key + :target `a}} + {:key `a+di-update-key#0-target + :description {:kind :service + :var #'a}} + {:key `a+di-update-key#0-f}] (di/inspect `a (di/update-key `a str)))))