This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # adventofcode (202)
- # aleph (8)
- # announcements (13)
- # architecture (1)
- # aws (2)
- # beginners (201)
- # boot (1)
- # bristol-clojurians (1)
- # calva (2)
- # cider (23)
- # cljs-dev (22)
- # cljsrn (2)
- # clojure (105)
- # clojure-bangladesh (1)
- # clojure-berlin (8)
- # clojure-dev (104)
- # clojure-europe (3)
- # clojure-italy (5)
- # clojure-losangeles (1)
- # clojure-nl (24)
- # clojure-russia (55)
- # clojure-spec (44)
- # clojure-uk (19)
- # clojurescript (58)
- # component (58)
- # cursive (3)
- # data-science (1)
- # datomic (27)
- # duct (6)
- # events (6)
- # figwheel-main (6)
- # fulcro (15)
- # jobs (3)
- # kaocha (5)
- # luminus (1)
- # music (1)
- # nrepl (2)
- # off-topic (24)
- # onyx (1)
- # pedestal (3)
- # protorepl (8)
- # re-frame (18)
- # reagent (39)
- # reitit (1)
- # remote-jobs (1)
- # ring (15)
- # rum (11)
- # shadow-cljs (5)
- # sql (8)
- # tools-deps (12)
- # vim (7)
I am trying to test a subsystem in some smoke tests but cant find a clear way to get the substem from the entire system map? I for example build the system map and start the system usually in production, but in test i want to take this system map and only start one component or some nested components but all the dependents are nil. any way around this?
Or if you're trying to start just that component, remember to specify
using for its dependencies (and build those too).
so say i have a large map. ideally i would be able to do:
(component/start-system (:component-with-dependents (large-map)))
That's kind of the point of Component -- you can build only the piece you care about for your tests, and provide whatever dependencies you want. So you can mock things out for subcomponent testing.
If you tests are about a subcomponent, they shouldn't even reference the full system.
Component is intended to let you provide mock dependencies. That's part of its power for testing.
probably the best plan then is to build a separate test-system-map for each part im testing
For example, at World Singles Networks, we have an "Application" Component with dependencies on Environment, Datasource, Caches components. Datasource and Caches depend on Environment. For the tests on Environment-related stuff, we just build Environment, nothing else. For the tests on Caches, we build the Caches component with an Environment component.
Well then you probably want to build and start the whole application component and run tests on that?
Once it is started, you can reach in and pull components out to work with (and they will all be started and have their dependencies).
Then your smoke tests will have to build the parts they're interested in, with their dependencies.
If you're not testing the complete system map, ignore it. Build the components you are interested in, with their dependents, and start just those parts.
yes. For example i have this:
instead id like to:
(def test-dpp-client-system-map (component/system-map :cache-client (cache-client/make-component (:cache-client helpers/config)) :dpp-client (component/using (cpp/make-component (:dpp-client helpers/config)) [:cache-client])))
def test-dpp-client-system-map (some-how-start-dependents-with-this-top-level-component-in-a-cleaner-way (:dpp-client production-system-map))
i was just wondering if there were more concise albeit implicit ways of also starting the dependents of the thing you are starting
test-dpp-client-system-map would need to create and hold the
:cache-client component since
:dpp-client depends on it. You can't get away from that.
right, i was just wondering if there were out of the box ways, say using the dependency-graph for component to intelligently infer that i want that started first
:dpp-client's value, that other data is not visible/accessible -- it's not part of that subcomponent.
It's only when you
start things that the actual component values get injected -- which means that whatever is started has to have access to all those components. Until that point, the metadata is just keywords.
even though we are standardized here and can probably make a macro or something to do just that
(it would probably have helped you if
component/start threw an exception if a dependency could not be found/injected rather than just leaving things as
You are correct
Missing dependency :b of clojure.lang.PersistentArrayMap expected in system at :b
annoyingly it does lose dependency information with select keys, but if you manually dissoc the components you don't want it works