-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently, transitive dependencies are being started in the order they were loaded, not in dependency order. This can cause issues in situations where new states which are needed for substitutes are loaded much later than the original state that is being overridden to depend on those new states. An example of this is in a test environment where you may have configuration overrides that you wouldn't define in your production overrides that are loaded from dev-only code. Without this change, the new test that was written failed because the newly added dependency was not loaded first. I had to do a bit of a hack to remove a state defined by defstate-let me know if there is a better way of doing this.
- Loading branch information
1 parent
16c686f
commit 8113709
Showing
3 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
(ns mount.extensions.common-deps-test | ||
(:require | ||
[clojure.test :refer [deftest testing is]] | ||
[mount.extensions.common-deps :as sut])) | ||
|
||
(def system "system") | ||
|
||
(def graphs | ||
{:dependencies {::overrides #{::overrides-a ::overrides-b} | ||
::config-a #{} | ||
::overrides-a #{::config-a} | ||
::config-b #{} | ||
::registry #{} | ||
::config #{::overrides ::env} | ||
::system #{::config ::debug ::db} | ||
::debug #{} | ||
::db #{::config} | ||
::env #{} | ||
::overrides-b #{::config-b}} | ||
:dependents {::overrides #{::config} | ||
::config-a #{::overrides-a} | ||
::overrides-a #{::overrides} | ||
::config-b #{::overrides-b} | ||
::registry #{} | ||
::config #{::system ::db} | ||
::system #{} | ||
::debug #{::system} | ||
::db #{::system} | ||
::env #{::config} | ||
::overrides-b #{::overrides}}}) | ||
|
||
(def states | ||
[::overrides | ||
::config-a | ||
::overrides-a | ||
::config-b | ||
::registry | ||
::config | ||
::system | ||
::debug | ||
::db | ||
::env | ||
::overrides-b]) | ||
|
||
(deftest transitives-test | ||
(testing "ordering active states in dependency order" | ||
(is (= [::debug | ||
::env | ||
::config-b | ||
::overrides-b | ||
::config-a | ||
::overrides-a | ||
::overrides | ||
::config | ||
::db | ||
::system] | ||
(sut/transitives #'system graphs states))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters