|
11 | 11 | ;; Debugging
|
12 | 12 | (def ^:private verbose? false)
|
13 | 13 | (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)) |
14 | 16 |
|
15 | 17 | ;; Helpers
|
16 | 18 | (defn- get-conn [config]
|
|
19 | 21 | (catch Exception _ (println "Unable to connect to db using:" config))))
|
20 | 22 |
|
21 | 23 | (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 |
24 | 26 | :dbname (or (System/getenv "PGDATABASE") "postgres")
|
25 | 27 | :user (or (System/getenv "PGUSERNAME") "postgres")
|
26 | 28 | :password (or (System/getenv "PGPASSWORD") "")}))
|
27 | 29 |
|
28 | 30 | (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 |
31 | 33 | :dbname tri-test
|
32 | 34 | :user tri-test
|
33 | 35 | :password tri-test}))
|
|
71 | 73 | ; Arrange
|
72 | 74 |
|
73 | 75 | ; Act
|
74 |
| - (migrate! tri-test tri-test tri-test verbose?) |
| 76 | + (migrate! pg-host pg-port tri-test tri-test tri-test verbose?) |
75 | 77 |
|
76 | 78 | ; Assert
|
77 | 79 | (with-open [^Connection conn (get-tri-test-conn)]
|
|
89 | 91 | (spit (str m/*migrations-dir* filename) contents)
|
90 | 92 |
|
91 | 93 | ; Act
|
92 |
| - (migrate! tri-test tri-test tri-test verbose?) |
| 94 | + (migrate! pg-host pg-port tri-test tri-test tri-test verbose?) |
93 | 95 |
|
94 | 96 | ; Assert
|
95 | 97 | (with-open [^Connection conn (get-tri-test-conn)]
|
|
105 | 107 |
|
106 | 108 | ; Act
|
107 | 109 | (dotimes [_ 5]
|
108 |
| - (migrate! tri-test tri-test tri-test verbose?)) |
| 110 | + (migrate! pg-host pg-port tri-test tri-test tri-test verbose?)) |
109 | 111 |
|
110 | 112 | ; Assert
|
111 | 113 | (with-open [^Connection conn (get-tri-test-conn)]
|
|
126 | 128 | "CREATE TABLE pets (id serial PRIMARY KEY, pet_name varchar);")
|
127 | 129 |
|
128 | 130 | ; 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?))) |
130 | 132 |
|
131 | 133 | ; Assert
|
132 | 134 | (with-open [^Connection conn (get-tri-test-conn)]
|
|
143 | 145 | (spit (str m/*migrations-dir* "01-create-users-table.sql") "CREATE TABLE users (id serial PRIMARY KEY);")
|
144 | 146 |
|
145 | 147 | ; 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