forked from macourtney/Conjure
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Courtney
committed
Jul 31, 2009
1 parent
3247dab
commit f42293f
Showing
13 changed files
with
253 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
file_structure/default/script/destroyers/fixture_destroyer.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(ns destroyers.fixture-destroyer | ||
(:require [conjure.test.util :as util] | ||
[conjure.util.file-utils :as file-utils])) | ||
|
||
(defn | ||
#^{:doc "Prints out how to use the destroy fixture command."} | ||
usage [] | ||
(println "You must supply a model (Like message).") | ||
(println "Usage: ./run.sh script/destroy.clj fixture <model>")) | ||
|
||
(defn | ||
#^{:doc "Destroys the fixture from the given model."} | ||
destroy-fixture-file [model] | ||
(if model | ||
(let [fixture-dir (util/find-fixture-directory)] | ||
(if fixture-dir | ||
(let [fixture-file (util/fixture-file model fixture-dir)] | ||
(if fixture-file | ||
(let [is-deleted (. fixture-file delete)] | ||
(println "File" (. fixture-file getName) (if is-deleted "destroyed." "not destroyed.")) | ||
(file-utils/delete-all-if-empty fixture-dir)) | ||
(println "Fixture file not found. Doing nothing."))) | ||
(do | ||
(println "Could not find the fixture directory.") | ||
(println "Command ignored.")))) | ||
(usage))) | ||
|
||
(defn | ||
#^{:doc "Destroys a fixture file for the model given in params."} | ||
destroy-fixture [params] | ||
(destroy-fixture-file (first params))) | ||
|
||
(defn | ||
#^{:doc "Destroys all of the files created by the model_test_generator."} | ||
destroy-all-dependencies [model] | ||
(destroy-fixture-file model)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
file_structure/default/script/generators/fixture_generator.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(ns generators.fixture-generator | ||
(:require [conjure.model.util :as model-util] | ||
[conjure.test.builder :as test-builder] | ||
[conjure.test.util :as test-util] | ||
[conjure.util.file-utils :as file-utils])) | ||
|
||
(defn | ||
#^{:doc "Prints out how to use the generate fixture command."} | ||
usage [] | ||
(println "You must supply a model name (Like hello-world).") | ||
(println "Usage: ./run.sh script/generate.clj fixture <model>")) | ||
|
||
(defn | ||
#^{:doc "Generates the fixture file for the given model."} | ||
generate-fixture-file [model] | ||
(let [fixture-file (test-builder/create-fixture model)] | ||
(if fixture-file | ||
(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.model.database)) | ||
(def " model "-fixture [function] | ||
(insert-into " table-name " | ||
; Add your test data here. | ||
{ :id 1 }) | ||
(function) | ||
(delete " table-name " \"true\"))")] | ||
(file-utils/write-file-content fixture-file fixture-content))))) | ||
|
||
(defn | ||
#^{:doc "Generates a fixture file for the model name in params."} | ||
generate-fixture [params] | ||
(generate-fixture-file (first params))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.