Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Migrate during test fixtures.

  • Loading branch information...
commit a7c72a91b7835b33e2d19522603f75d66a3e9368 1 parent 7faca64
@technomancy authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 test/clojars/test/test_helper.clj
View
11 test/clojars/test/test_helper.clj
@@ -1,9 +1,11 @@
(ns clojars.test.test-helper
(import java.io.File)
(:require [clojars.db :as db]
+ [clojars.db.migrate :as migrate]
[clojars.config :as config]
[korma.db :as kdb]
[clojure.test :as test]
+ [clojure.java.shell :as sh]
[clojure.java.io :as io]
[clojure.java.jdbc :as jdbc]))
@@ -22,9 +24,18 @@
(delete-file-recursively child)))
(io/delete-file f))))
+(defonce migrate
+ (delay
+ (let [db (:subname (:db config/config))]
+ (when-not (.exists (io/file db))
+ (.mkdirs (.getParentFile (io/file db)))
+ (sh/sh "sqlite3" db :in (slurp "clojars.sql"))))
+ (migrate/-main)))
+
(defn use-fixtures []
(test/use-fixtures :each
(fn [f]
+ (force migrate)
(let [file (File. (:repo config/config))]
(delete-file-recursively file))
(f)
Please sign in to comment.
Something went wrong with that request. Please try again.