Skip to content

Commit

Permalink
Add :override metadata to default expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Apr 26, 2024
1 parent 6c6ae51 commit e7e41ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/integrant/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
{:arglists '([key value])}
(fn [key _value] (normalize-key key)))

(defmethod expand-key :default [k v] {k v})
(defmethod expand-key :default [k v] ^:override {k v})

(defmulti init-key
"Turn a config value associated with a key into a concrete implementation.
Expand Down
7 changes: 5 additions & 2 deletions test/integrant/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@
(is (= (ig/expand {::mod {:x 1}, ::a ^:override {:x 2}})
{::a {:x 2}, ::b {:v {:x 1}}})))
(testing "expand with nested override"
(is (= (ig/expand {::mod 1, ::b ^:override {:v 2}})
{::a 1, ::b {:v 2}}))
(is (= (ig/expand {::mod {:x 1, :y 1}, ::mod-a ^:override {:y 2}})
{::a {:x 1, :y 2}, ::b {:v {:x 1, :y 1}}}))
(is (= (ig/expand {::mod-c 1, ::c ^:override {:x {:y {:z 2}}}})
{::c {:x {:y {:z 2}}}})))
(testing "expand with default override"
(is (= (ig/expand {::mod 1, ::a 2}) {::a 2, ::b {:v 1}}))
(is (= (ig/expand {::mod 1, ::b {:v 2}}) {::a 1, ::b {:v 2}})))
(testing "unresolved conflicting index"
(is (thrown-with-msg?
#?(:clj clojure.lang.ExceptionInfo :cljs cljs.core.ExceptionInfo)
Expand Down

0 comments on commit e7e41ee

Please sign in to comment.