If I understand you correctly, you are talking about using something like WireMock with integrant. I don’t give you a code example, but I can summary how I would use it: - extract the endpoint url as a integrant key - in the test system configuration - make the WireMock a :required key for the component consuming the endpoint url (to keep the correct initialisation order) - replace endpoint url by WireMock url - in your integration tests, you declare the response you want to receive for given request. I hope that will help.
I was wondering, if I'm referencing integrant.core :as ig why does aero not look for that when it attempts to read it.
if I have #ig/ref in my config
I guess I have to do something like
(binding [*data-readers* {'ig/ref ig/ref}]
(aero/read-config (<http://clojure.java.io/resource|clojure.java.io/resource> "config.edn")))
You can just defmethod the reader, take my snippet above and replace component with ig/ref. Aero has its own multimethod for adding readers.
Cool I think I got a good solution using aero, consolidates things nicely, just took some time experimenting
@grzegorzrynkowski_clo thanks for taking the time! I will try that out. I had not heard of WireMock previously.
1👍is there a way in aero to have a key completely removed from the final map. Let's say I have a key that's solely used from importing, and referenced by other areas of the config, but since integrant only allows keys that have an init, I want it to not be there in the final output. I figured I can just disassoc it from the map before doing integrant, but figured there may be an easier way to just ignore it altogether.
@theeternalpulse If I understand you correctly, you declare in your config map some kind of intermediary/helper component (that you use in some other components as a dependency) and you don’t want to have it in the final system map built by integrant. If that is correct I don’t think there is a solution out of the box. As you noticed you can dissoc it, but I think ignoring it is probably the best option. Integrant is not designed to keep only the major components of your system. It is designed to contain all the elements (even the smallest) that are relevant for initialising your system. In #duct, the extension of the Integrant concept, you can notice that Duct contains special key type for const values, so in the design, Duct encourages to keep even such a single values in the final system map. I mean the idea of removing it, it is quite interesting, although personally, I don’t see a lot of value in it. I like to have all the intermediary elements so I can see what data had been used to initiate all of my components. If I cut them off, it is not easy or it is even impossible to check from REPL what data had been used to initialise the components. I hope that helps 🙂
I guess dissoc'ing only at the final use is the best, allows debugging of the entire config at some point easier
I only have an "ignored" key because aero has functionality to do something like
:app-config #include #join [#or [#env HOME
#env CONFIG-DIR] "/.parrot.config.edn"]
and ref it in the config at load-time
the aero ref not integrant
I guess I can just make a dummy init that returns that same config
but dissoc is just be the most straightforward