Skip to content

Commit bf6335c

Browse files
committed
Move clear-database util to prod classpath
The dev tooling is on the prod classpath, so can't use the test classpath since we AOT everything. This moves the clear-database util to a dev tooling ns to allow AOT to work. There are a couple of issues here that we should address in the future: - dev tooling shouldn't be on the prod CP - we shouldn't AOT everything, just a main entry point
1 parent fcc2c18 commit bf6335c

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/clojars/dev/setup.clj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
[clojars.file-utils :as fu]
77
[clojars.search :as search]
88
[clojars.stats :as stats]
9-
[clojars.test-helper :as help]
109
[clojure.java.io :as io]
10+
[clojure.java.jdbc :as jdbc]
1111
[clojure.string :as str])
1212
(:import
1313
(org.apache.maven.artifact.repository.metadata
@@ -17,6 +17,18 @@
1717
MetadataXpp3Reader
1818
MetadataXpp3Writer)))
1919

20+
(defn clear-database! [db]
21+
(try
22+
(jdbc/db-do-commands
23+
db
24+
["delete from deps"
25+
"delete from groups"
26+
"delete from jars"
27+
"delete from users"
28+
"delete from group_verifications"
29+
"delete from audit"])
30+
(catch Exception _)))
31+
2032
(defn add-test-users
2133
"Adds n test users of the form test0/test0."
2234
[db n]
@@ -114,7 +126,7 @@
114126
(println "Aborting.")
115127
(System/exit 1))
116128
(println "==> Clearing the" db "db...")
117-
(help/clear-database db)
129+
(clear-database! db)
118130
(println "==> Creating 10 test users...")
119131
(let [test-users (add-test-users db 10)]
120132
(println "==> Importing" repo "into the db...")

test/clojars/test_helper.clj

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[clojars.config :as config]
55
[clojars.db :as db]
66
[clojars.db.migrate :as migrate]
7+
[clojars.dev.setup :as setup]
78
[clojars.email :as email]
89
[clojars.errors :as errors]
910
[clojars.oauth.service :as oauth-service]
@@ -69,17 +70,7 @@
6970

7071
(declare ^:dynamic *db*)
7172

72-
(defn clear-database [db]
73-
(try
74-
(jdbc/db-do-commands
75-
db
76-
["delete from deps"
77-
"delete from groups"
78-
"delete from jars"
79-
"delete from users"
80-
"delete from group_verifications"
81-
"delete from audit"])
82-
(catch Exception _)))
73+
(def clear-database setup/clear-database!)
8374

8475
(defn with-clean-database [f]
8576
(binding [config/*profile* "test"]

0 commit comments

Comments
 (0)