This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-17
Channels
- # bangalore-clj (1)
- # beginners (70)
- # boot (1)
- # cider (39)
- # cljs-dev (69)
- # clojure (56)
- # clojure-dev (1)
- # clojure-norway (1)
- # clojure-russia (4)
- # clojure-spec (1)
- # clojure-uk (10)
- # clojurescript (34)
- # clr (3)
- # community-development (3)
- # component (1)
- # datascript (1)
- # datomic (7)
- # emacs (1)
- # figwheel (3)
- # fulcro (5)
- # graphql (2)
- # hoplon (75)
- # jobs (4)
- # jobs-discuss (1)
- # luminus (15)
- # planck (3)
- # portkey (55)
- # re-frame (2)
- # reagent (2)
- # reitit (3)
- # ring (13)
- # ring-swagger (1)
- # shadow-cljs (72)
- # spacemacs (4)
- # tools-deps (2)
- # unrepl (7)
- # vim (2)
Hello! Apologies if this is a beginner question asked somewhere more appropriate, but: I've been trying to convert Eric Normand's article on using database transactions for quicker integration test cleanup into something that works with component. So far I have:
(defn with-transaction-fixture
[f]
(let [db (:db *system*)
spec (:spec db)]
(dbc/migrate db)
(sql/with-db-transaction [spec spec]
(sql/db-set-rollback-only! spec)
(binding [*system* (assoc-in *system* [:db :spec] spec)]
(f)))))
which worked well originally, until I put a bunch of my logic into a second component for business logic which uses the db component as a dependency.
I could write a second fixture that performs the binding on that second component, but I'm wondering if there's something that wouldn't require a variant for every db-using-component I define and test. This feels like a pattern that should be common and yet I'm not seeing many examples of it in github for some reason (perhaps I don't know the right code-snippet to look for)