Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(run-tests) in repl gets :dev environment variables #24

Closed
visibletrap opened this issue Jan 30, 2015 · 2 comments
Closed

(run-tests) in repl gets :dev environment variables #24

visibletrap opened this issue Jan 30, 2015 · 2 comments

Comments

@visibletrap
Copy link
Contributor

In my development workflow, I normally run my tests in the repl with (run-tests). Assume that my profiles.clj has this content:

{:dev  {:env {:database-url "jdbc:postgres://localhost/dev"}}
 :test {:env {:database-url "jdbc:postgres://localhost/test"}}}
  • When I run tests through lein test, database-url from :test is used as expected
  • When running tests in repl, the tests always use :database-url from :dev.

I know that env in :dev is loaded on repl start, they can't be modified and the (run-tests) uses them.

Is there a way to let (run-tests) uses env from :test and at the same time same repl, if I eval code manually, env from :dev are used?

@weavejester
Copy link
Owner

You might want to read this comment.

You should consider your environment and your application configuration to be two different things. You may derive a configuration from the environment, but they should not be viewed as equivalent.

Ideally you should have some function that, given a configuration map, creates your application. This means you can populate it with environment variables, or, in the case of tests, with test data instead.

@visibletrap
Copy link
Contributor Author

Thanks for the quick response and clarification. I now completely understand your thinking and the position of this library. I really appreciate your thought and efforts putting in it. Thank you.

Environment has been an easy go-to place for my team allowing different setup between among member development machines and also production system. I can't think of many things in my day to day development that can be categorized as environment but not application configuration, so to me separating them seems to be unnecessary more work. But anyway, I'll find the other way around this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants