Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (49 sloc) 1.911 kB
(ns clojars.test.test-helper
(:require [clojars.db :as db]
[clojars.db.migrate :as migrate]
[clojars.config :refer [config]]
[korma.db :as kdb]
[clucy.core :as clucy]
[clojure.test :as test]
[ :as sh]
[ :as io]
[ :as jdbc]))
(def local-repo (io/file (System/getProperty "")
"clojars" "test" "local-repo"))
(def local-repo2 (io/file (System/getProperty "")
"clojars" "test" "local-repo2"))
(defn delete-file-recursively
"Delete file f. If it's a directory, recursively delete all its contents."
(let [f (io/file f)]
(when (.exists f)
(when (.isDirectory f)
(doseq [child (.listFiles f)]
(delete-file-recursively child)))
(io/delete-file f))))
(defonce migrate
(let [db (:subname (:db config))]
(when-not (.exists (io/file db))
(.mkdirs (.getParentFile (io/file db)))
(sh/sh "sqlite3" db :in (slurp "clojars.sql"))))
(defn default-fixture [f]
(force migrate)
(delete-file-recursively (io/file (config :repo)))
(delete-file-recursively (io/file (config :event-dir)))
(.mkdirs (io/file (config :event-dir)))
(delete-file-recursively (io/file (config :stats-dir)))
(.mkdirs (io/file (config :stats-dir)))
(spit (io/file (config :stats-dir) "all.edn") "{}")
(jdbc/with-connection (kdb/get-connection @kdb/_default)
"delete from users;" "delete from jars;" "delete from groups;"))
(defn index-fixture [f]
(delete-file-recursively (io/file (config :index-path)))
(with-open [index (clucy/disk-index (config :index-path))]
(clucy/add index {:dummy true})
(clucy/search-and-delete index "dummy:true"))
Jump to Line
Something went wrong with that request. Please try again.