-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/15/2012 06:18 PM, Matt Stump wrote: > > > Is there a way to set different values for global vars when running > tests as opposed to the development or production environment? I > need to control which database my tests for a noir project connect > to. Ideally I would like to do something like the following: for > production and development, if an environment variable is set > connect to the database server at the specified URL, if not then > fall back to localhost. For test start up an embedded server, and > connect. After the test is done, rollback the global var to the > previous value and resume connecting to the server on localhost or > at the location specified by the environment variable. > > I could create some fixture with-test-database that modifies a > global var, but that seems a little hackish. > > How are other people solving this problem? Is there something > similar pre-baked into noir, clojure.test or midje? >
I wrote support for configuration with different environments into Ciste.[1] You create a config.clj file at the root of your application that contains a map with each of the keys being a keyword naming the environment and the value is a map for all the config options. You can then use set-environment! or with-environment to set the current environment. You can then wrap some code in definitializer. That code will be run whenever the environment changes. I set the environment when my application runs and then wrap all my tests in (with-environment :test ) The config namespace should be isolated enough that you could use it without involving any of the other features. 1: https://github.com/duck1123/ciste/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8ZoO0ACgkQWorbjR01Cx59cACffeQeffgR0zgtqt5FXGaQy9gx zz8An2pMclSd+qA8dxc8XMPB+gMbhNjR =XbSs -----END PGP SIGNATURE----- -- 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