Skip to content

Commit

Permalink
Use cedric/make-connection in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan committed Feb 28, 2024
1 parent 9b06658 commit 60be5b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/swark/cedric.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@

(comment
(let [connection (-> "/tmp/testdb123.csv" Csv. make-connection)]
(def transact! (::transact! connection))
(def close! (::close! connection)))
(def transact! (::transact! connection)) ; Define transact! for this connection
(def close! (::close! connection))) ; Define close! for this connection

;; Upsert items via the transact! function
(transact! upsert-items {:primary-key :user/id} [{:user/name "Arnold"} {:user/name "Naomi"} {:user/name "Theodor"}])
Expand Down
16 changes: 7 additions & 9 deletions test/swark/cedric_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@
;; Test all implementations in exactly the same way!
(doseq [make-db [#(Mem. (atom nil))
#(Csv. (str "/tmp/testdb-" (swark/unid) ".csv"))]]
(let [db (make-db)
db-conn (swark/atomic db)
transact! (partial swark/put! db-conn)
props {:primary-key :person/id}
the-names (some-names 25)
persons (map (partial assoc nil :person/name) the-names)
result (transact! sut/upsert-items props persons)]
;; result
(let [{::sut/keys
[transact! close!]} (sut/make-connection (make-db))
props {:primary-key :person/id}
the-names (some-names 25)
persons (map (partial assoc nil :person/name) the-names)
result (transact! sut/upsert-items props persons)]
(testing "upsert-items"
(testing "returns the upserted items"
(is (-> result count (= 25)))
Expand All @@ -82,4 +80,4 @@
(is (= {::sut/archived 5} archived))))
(testing "returns all the items"
(is (-> (transact! sut/read-items {}) count #{20})))
(swark/close! db-conn))))
(close!))))

0 comments on commit 60be5b5

Please sign in to comment.