Skip to content

Commit 9629efa

Browse files
committed
Fix migrate tests
1 parent f91158e commit 9629efa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/triangulum/migrate_test.clj

+11-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
;; Debugging
1212
(def ^:private verbose? false)
1313
(def ^:private tri-test "tri_test")
14+
(def ^:private pg-host (or (System/getenv "PGHOST") "localhost"))
15+
(def ^:private pg-port (or (System/getenv "PGPORT") 5432))
1416

1517
;; Helpers
1618
(defn- get-conn [config]
@@ -19,15 +21,15 @@
1921
(catch Exception _ (println "Unable to connect to db using:" config))))
2022

2123
(defn- get-admin-conn []
22-
(get-conn {:host (or (System/getenv "PGHOST") "localhost")
23-
:port (or (System/getenv "PGPORT") 5432)
24+
(get-conn {:host pg-host
25+
:port pg-port
2426
:dbname (or (System/getenv "PGDATABASE") "postgres")
2527
:user (or (System/getenv "PGUSERNAME") "postgres")
2628
:password (or (System/getenv "PGPASSWORD") "")}))
2729

2830
(defn- get-tri-test-conn []
29-
(get-conn {:host (or (System/getenv "PGHOST") "localhost")
30-
:port (or (System/getenv "PGPORT") 5432)
31+
(get-conn {:host pg-host
32+
:port pg-port
3133
:dbname tri-test
3234
:user tri-test
3335
:password tri-test}))
@@ -71,7 +73,7 @@
7173
; Arrange
7274

7375
; Act
74-
(migrate! tri-test tri-test tri-test verbose?)
76+
(migrate! pg-host pg-port tri-test tri-test tri-test verbose?)
7577

7678
; Assert
7779
(with-open [^Connection conn (get-tri-test-conn)]
@@ -89,7 +91,7 @@
8991
(spit (str m/*migrations-dir* filename) contents)
9092

9193
; Act
92-
(migrate! tri-test tri-test tri-test verbose?)
94+
(migrate! pg-host pg-port tri-test tri-test tri-test verbose?)
9395

9496
; Assert
9597
(with-open [^Connection conn (get-tri-test-conn)]
@@ -105,7 +107,7 @@
105107

106108
; Act
107109
(dotimes [_ 5]
108-
(migrate! tri-test tri-test tri-test verbose?))
110+
(migrate! pg-host pg-port tri-test tri-test tri-test verbose?))
109111

110112
; Assert
111113
(with-open [^Connection conn (get-tri-test-conn)]
@@ -126,7 +128,7 @@
126128
"CREATE TABLE pets (id serial PRIMARY KEY, pet_name varchar);")
127129

128130
; Act
129-
(is (thrown? Exception (migrate! tri-test tri-test tri-test verbose?)))
131+
(is (thrown? Exception (migrate! pg-host pg-port tri-test tri-test tri-test verbose?)))
130132

131133
; Assert
132134
(with-open [^Connection conn (get-tri-test-conn)]
@@ -143,4 +145,4 @@
143145
(spit (str m/*migrations-dir* "01-create-users-table.sql") "CREATE TABLE users (id serial PRIMARY KEY);")
144146

145147
; Act/Assert
146-
(is (thrown? Exception (migrate! tri-test tri-test tri-test false)))))
148+
(is (thrown? Exception (migrate! pg-host pg-port tri-test tri-test tri-test false)))))

0 commit comments

Comments
 (0)