From 259d5cdd849216e9a14c3a27494b3135eb309622 Mon Sep 17 00:00:00 2001 From: James Reeves Date: Sat, 31 Aug 2024 23:06:29 +0100 Subject: [PATCH] Fix indexes with same value from being conflicts If two expansions use the same index, it's not a conflict if the values are identical. --- src/integrant/core.cljc | 2 +- test/integrant/core_test.cljc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/integrant/core.cljc b/src/integrant/core.cljc index c268b82..5669dc9 100644 --- a/src/integrant/core.cljc +++ b/src/integrant/core.cljc @@ -494,7 +494,7 @@ (remove (comp override-indexes :index)) (group-by :index) (vals) - (filter next)))) + (filter #(->> % (map :value) set next))))) (defn- converge-conflict-exception [config expansions] (let [index (-> expansions first :index) diff --git a/test/integrant/core_test.cljc b/test/integrant/core_test.cljc index 72b51d5..2a68027 100644 --- a/test/integrant/core_test.cljc +++ b/test/integrant/core_test.cljc @@ -322,6 +322,11 @@ "when converging: :integrant\\.core-test/mod, " ":integrant\\.core-test/mod-b\\.")) (ig/expand {::mod 1, ::mod-b 2})))) + (testing "conflicting keys with same value" + (is (= (ig/expand {::mod {:x 1} ::mod-a {:x 1}}) + {::a {:x 1}, ::b {:v {:x 1}}})) + (is (= (ig/expand {::mod {:x 1} ::mod-a {:x 1} ::mod-b {:x 1}}) + {::a {:x 1}, ::b {:v {:x 1}}}))) (testing "resolved conflict" (is (= (ig/expand {::mod {:x 1}, ::mod-a {:x 2}, ::a {:x 3}}) {::a {:x 3}, ::b {:v {:x 1}}})))