Skip to content

Commit

Permalink
Fix indexes with same value from being conflicts
Browse files Browse the repository at this point in the history
If two expansions use the same index, it's not a conflict if the values
are identical.
  • Loading branch information
weavejester committed Aug 31, 2024
1 parent 99d8470 commit 259d5cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/integrant/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/integrant/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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}}})))
Expand Down

0 comments on commit 259d5cd

Please sign in to comment.