Permalink
Browse files

Added missing test for the special uses of the column function.

  • Loading branch information...
1 parent ee1219c commit a483be313ba070301932287db8f7164150abb930 @budu budu committed Aug 20, 2011
Showing with 13 additions and 5 deletions.
  1. +3 −3 src/lobos/schema.clj
  2. +10 −2 test/lobos/test/schema.clj
View
6 src/lobos/schema.clj
@@ -423,7 +423,7 @@
handled
* `:time-zone` (for time types) determines if the type includes a time-zone
-It also can be used in alter modify and rename actions. In that
+ It also can be used in alter modify and rename actions. In that
case, if data-type is :to, it acts as a column rename clause and if
data-type is :drop-default, it acts as a column drop default clause."
{:arglists '([table column-name data-type? & options])}
@@ -446,8 +446,8 @@ It also can be used in alter modify and rename actions. In that
(update-in table [:columns] conj
[column-name
(case (first options)
- :to (Column. column-name nil nil nil nil (second options))
- :drop-default (Column. column-name nil :drop nil nil nil)
+ :to (Column. column-name nil nil false false (second options))
+ :drop-default (Column. column-name nil :drop false false [])
(column* column-name data-type options))]))))
;; -----------------------------------------------------------------------------
View
12 test/lobos/test/schema.clj
@@ -108,7 +108,7 @@
;;;; Column definition tests
(def column-definition-stub
- (Column. :foo nil nil false false []))
+ (Column. :foo nil nil false false []))
(deftest test-column
(testing "Column definition"
@@ -133,7 +133,15 @@
(is (= (table :foo (column :foo nil "BAR"))
(table* :foo {:foo (assoc column-definition-stub
:others ["BAR"])} {} {}))
- "Setting custom options")))
+ "Setting custom options")
+ (is (= (table :foo (column :foo :to :bar))
+ (table* :foo {:foo (assoc column-definition-stub
+ :others :bar)}))
+ "Should set :others value to the new column name")
+ (is (= (table :foo (column :foo :drop-default))
+ (table* :foo {:foo (assoc column-definition-stub
+ :default :drop)}))
+ "Should set :default value to :drop")))
(deftest test-typed-column
(testing "Typed column definition"

0 comments on commit a483be3

Please sign in to comment.