integrant

kirill.salykin 2020-02-18T15:34:54.006800Z

hello how do people replace keys in the system-map during tests? for instance there is system-map with

{::config {}
 ::db {:config (ig/ref ::config)}}
how would you replace ::config with test config?

kwrooijen 2020-02-18T15:39:54.007600Z

You could use merge, or the meta-merge package to replace keys before ig/init

kirill.salykin 2020-02-18T15:42:40.008300Z

I assume I also should change all ig/ref to use different keyword?

kwrooijen 2020-02-18T15:43:29.009100Z

You shouldn't have to do that, as long as the contents of those keys change before ig/init

2020-02-18T15:44:00.009900Z

You don’t have to. If you want separate behaviour, you can use two different keys that derive from the same parent.

2020-02-18T15:44:16.010300Z

e.g. ::prod-config and ::test-config might derive from ::config

2020-02-18T15:44:28.010600Z

assuming you need a different ig/init-key method.

kirill.salykin 2020-02-18T15:45:46.010800Z

and I should not require ::prod-config namespace, otherwise wrong init-key might be used?

2020-02-18T15:47:07.011Z

No, the method is chosen based on the key name. So a init-key for ::prod-config will only work for ::prod-config.

kirill.salykin 2020-02-18T15:47:43.011200Z

{::test-config {}
 ::db {:config (ig/ref ::config)}}
will do what I expect? (assuming (derive ::test-config ::config)

kirill.salykin 2020-02-18T15:55:21.011400Z

Ambiguous key: 
Maybe I am doing something wrong…

2020-02-18T15:55:58.011600Z

You have to make sure that only one of ::test-config and ::prod-config is in your config map.

2020-02-18T15:56:13.011800Z

Otherwise (ig/ref ::config) doesn’t know which one you mean.

kirill.salykin 2020-02-18T15:58:26.012Z

oh, found the issue works, thank you!