This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-25
Channels
- # anglican (2)
- # babashka (53)
- # beginners (99)
- # brompton (1)
- # calva (28)
- # circleci (43)
- # clj-commons (4)
- # clj-kondo (176)
- # cljsrn (22)
- # clojars (7)
- # clojure (175)
- # clojure-australia (2)
- # clojure-europe (20)
- # clojure-germany (1)
- # clojure-uk (5)
- # clojurescript (195)
- # cursive (18)
- # datomic (13)
- # emacs (2)
- # farolero (9)
- # find-my-lib (6)
- # fulcro (8)
- # graalvm (12)
- # gratitude (5)
- # helix (11)
- # improve-getting-started (36)
- # introduce-yourself (3)
- # jackdaw (21)
- # jobs (2)
- # joker (2)
- # malli (65)
- # meander (24)
- # nbb (2)
- # off-topic (4)
- # pathom (2)
- # polylith (17)
- # portal (5)
- # react (3)
- # reagent (22)
- # releases (1)
- # ring (4)
- # shadow-cljs (79)
- # show-and-tell (2)
- # testing (5)
- # tools-deps (9)
- # xtdb (12)
Hi, my project connects to a postgres db using a simple (def db (jdbc/get-datasource (System/getenv "DATABASE_URL")
in my db namespace. When running my tests, I want to set that env variable to point to my test db. What would be a recommended way to set that env variable when running my tests? Right now Iām just setting it on the command line: DATABASE_URL=<test-db-url> clj -M:test
, but I would ideally like to have it in my deps.edn :test alias. Is that possible?
@josephson.victor No, you can't set environment variables after a process starts up.
You could use a JVM property instead, which you could set with :jvm-opts
in your :test
alias.
Or do something like (or (System/getProperty "database.url") (System/getenv "DATABASE_URL"))
then you can override it via -Ddatabase.url=...
in JVM opts but still use the env var when that property is not set.
Thanks so much, @seancorfield, you have no idea how much I appreciate your help and contributions in the Clojure community š