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 7, 2009
1 parent
6891687
commit 459ee5b
Showing
2 changed files
with
71 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(ns test.model.test-util | ||
(:import [java.io File]) | ||
(:use clojure.contrib.test-is | ||
conjure.model.util) | ||
(:require [generators.model-generator :as model-generator] | ||
[destroyers.model-destroyer :as model-destroyer])) | ||
|
||
(def model-name "test") | ||
|
||
(defn setup-all [function] | ||
(model-generator/generate-model-file model-name) | ||
(function) | ||
(model-destroyer/destroy-model-file model-name)) | ||
|
||
(use-fixtures :once setup-all) | ||
|
||
(deftest test-model-from-file | ||
(is (= model-name (model-from-file (new File (str "models/" model-name ".clj"))))) | ||
(is (nil? (model-from-file nil)))) | ||
|
||
(deftest test-model-namespace | ||
(is (= (str "models." model-name) (model-namespace model-name))) | ||
(is (nil? (model-namespace nil)))) | ||
|
||
(deftest test-find-models-directory | ||
(let [models-dirctory (find-models-directory)] | ||
(is (not (nil? models-dirctory))) | ||
(is (instance? File models-dirctory)) | ||
(is (= "models" (. models-dirctory getName))))) | ||
|
||
(deftest test-model-file-name-string | ||
(is (= (str model-name ".clj") (model-file-name-string model-name))) | ||
(is (= "test_foo.clj" )(model-file-name-string "test-foo")) | ||
(is (= "test_foo.clj" )(model-file-name-string "test_foo")) | ||
(is (nil? (model-file-name-string nil)))) | ||
|
||
(deftest test-migration-for-model | ||
(let [migration-file-name (migration-for-model model-name)] | ||
(is (not (nil? migration-file-name))) | ||
(is (= "create-tests" migration-file-name))) | ||
(is (nil? (migration-for-model nil)))) | ||
|
||
(deftest test-model-to-table-name | ||
(is (= "tests" (model-to-table-name model-name))) | ||
(is (= "test_foos" (model-to-table-name "test-foo"))) | ||
(is (= "test_foos" (model-to-table-name "test_foo"))) | ||
(is (nil? (model-to-table-name nil)))) | ||
|
||
(deftest test-find-model-file | ||
(let [model-file (find-model-file (find-models-directory) model-name)] | ||
(is (not (nil? model-file))) | ||
(is (instance? File model-file)) | ||
(is (= "test.clj" (. model-file getName)))) | ||
(let [model-file (find-model-file model-name)] | ||
(is (not (nil? model-file))) | ||
(is (instance? File model-file)) | ||
(is (= "test.clj" (. model-file getName)))) | ||
(is (nil? (find-model-file nil))) | ||
(is (nil? (find-model-file nil model-name))) | ||
(is (nil? (find-model-file nil nil)))) |