what about just re-defing the function inside the tests to the instrumented version?
something like: (ns one.http) (defn get [] ...) (ns one.http-instrumented) (defn get [] ...) (ns one.test.blah) (with-redefs [one.http/get one.http-instrumented/get] ...) guess you could put the redefs into a function and use it as a fixture if you're using clojure.test? that would get rid of the flag and fork in the code O_o On Wed, Nov 30, 2011 at 5:53 PM, AndyK <andy.kri...@gmail.com> wrote: > I have Clojure code which makes HTTP requests to a server. Depending > on the context, I want to swap out the underlying HTTP library code. > For example, I use an instrumented library in a testing context and a > different library in a REPL context where the instrumented library > will not work. These are low-lying functions - the http/get and http/ > put - called within other functions for doing specific kinds of > requests which are called in turn by other functions. > > What I'm wondering is what are good ways to dynamically choose which > versions of those low-lying functions to use? > > For now, I'm doing this within the namespace that uses the low-lying > functions.. > > (def get (if (context-flag?) ns.one.http-instrumented/get ns.two.http- > repl/get)) > > What I don't like about this is that context-flag feeling like a hacky > approach. > > Thoughts? > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en