Permalink
Browse files

Updated the model test generator to initialize conjure before trying …

…to deal with the database.
  • Loading branch information...
1 parent 07bc21a commit 0fb07ed60ea88d820fcb67c4876dc9713ea33aa7 @macourtney committed Oct 4, 2010
View
@@ -9,7 +9,7 @@ Conjure is a Rails like framework for the Clojure programming language. The goal
To get started with Conjure, see the "Getting Started":http://wiki.github.com/macourtney/Conjure/getting-started wiki page.
-For a tutorial on Conjure, see the "Hello World tutorial":http://wiki.github.com/macourtney/Conjure/hello-world-tutorial-2
+For a tutorial on Conjure, see the "Hello World tutorial":http://github.com/macourtney/Conjure/wiki/Hello-World-Tutorial
You can find our google group at: "Conjure Google Group":http://groups.google.com/group/clojure-conjure
@@ -1,29 +0,0 @@
-(ns leiningen.hooks.copy-resource-deps
- (:use robert.hooke)
- (:require [clojure.contrib.logging :as logging]
- [clojure.java.io :as io]))
-
-(defn jar-file? [file]
- (and (not (.isDirectory file)) (.endsWith (.getName file) ".jar")))
-
-(defn delete-old-resource-files [resource-library-path]
- (let [resource-library-files (filter jar-file? (file-seq resource-library-path))]
- (println "Deleting" (count resource-library-files) "files from" (.getPath resource-library-path))
- (doseq [resource-library-file resource-library-files]
- (when-not (.delete resource-library-file)
- (throw (RuntimeException. (str "Could not delete resource library file: " resource-library-file)))))))
-
-(defn copy-new-resource-files [lein-project resource-library-path]
- (let [jar-files (filter jar-file? (file-seq (io/file (:library-path lein-project))))]
- (println "Copying" (count jar-files) "files to" (.getPath resource-library-path))
- (doseq [jar-file jar-files]
- (io/copy jar-file (io/file resource-library-path (.getName jar-file))))))
-
-(defn copy-resources [task & args]
- (apply task args)
- (let [lein-project (first args)
- resource-library-path (io/file (str (:root lein-project) "/resources/lib"))]
- (delete-old-resource-files resource-library-path)
- (copy-new-resource-files lein-project resource-library-path)))
-
-(add-hook #'leiningen.deps/deps copy-resources)
@@ -30,9 +30,13 @@
(def conjure-js (find-config-env-value :conjure-js "conjure.js"))
(defn
+ set-evironment-property [environment]
+ (java-utils/set-system-properties { conjure-environment-property environment }))
+
+(defn
require-environment []
(when (not (java-utils/get-system-property conjure-environment-property nil))
- (java-utils/set-system-properties { conjure-environment-property default-environment }))
+ (set-evironment-property default-environment))
(let [mode (java-utils/get-system-property conjure-environment-property nil)]
(require (symbol (str "config.environments." mode)))))
@@ -94,5 +94,4 @@ one." }
production, or test." }
set-mode [mode]
(when mode
- (java-utils/set-system-properties
- { environment/conjure-environment-property (conjure-str-utils/str-keyword mode) })))
+ (environment/set-evironment-property (conjure-str-utils/str-keyword mode))))
@@ -0,0 +1,13 @@
+(ns conjure.core.test.init
+ (:import [java.io File])
+ (:require [conjure.core.config.environment :as environment]
+ [conjure.core.server.server :as server]
+ [drift.execute :as drift-execute]))
+
+(defn
+ init-tests []
+ (when (not (deref server/initialized?))
+ (println "Initializing test database.")
+ (server/set-mode "test")
+ (server/init)
+ (drift-execute/migrate nil nil)))
@@ -1,5 +0,0 @@
-(ns conjure.core.script.noop)
-
-(defn
-#^{:doc "This script does nothing. It is used by the execute test."}
- run [args])
@@ -1,6 +0,0 @@
-(ns test-run
- (:use clojure.contrib.test-is
- run))
-
-(deftest test-render-view
- (-main "noop"))
@@ -19,7 +19,10 @@
(let [fixture-namespace (test-util/fixture-namespace model)
table-name (model-util/model-to-table-name model)
fixture-content (str "(ns " fixture-namespace "
- (:use conjure.core.model.database))
+ (:use conjure.core.model.database)
+ (:require [conjure.core.test.init :as test-init]))
+
+(test-init/init-tests)
(def records [
; Add your test data here.

0 comments on commit 0fb07ed

Please sign in to comment.