Tests for the previous patch (adding special time printing in postgres).
authorRuss Tyndall <russ@acceleration.net>
Thu, 9 Oct 2008 20:53:42 +0000 (16:53 -0400)
committerNathan Bird <nathan@acceleration.net>
Mon, 2 Feb 2009 19:31:28 +0000 (14:31 -0500)
Also including the time tests , which were not included prev

These tests will create a table and verify that the date inserted is
the date retrieved and that when we update the database the value we
retrieve is the same as the one we inserted.

tests/test-init.lisp
tests/test-time.lisp

index b0a902ca0502c8bd54c13ea1d3747df0f3ebdf84..57a3cfcb7135914e94171bcc31d23ee02a84d627 100644 (file)
   (let ((test-forms '())
         (skip-tests '()))
     (dolist (test-form (append *rt-internal* *rt-connection* *rt-basic* *rt-fddl* *rt-fdml*
-                               *rt-ooddl* *rt-oodml* *rt-syntax*))
+                               *rt-ooddl* *rt-oodml* *rt-syntax* *rt-time*
+                              ))
       (let ((test (second test-form)))
         (cond
           ((and (null (clsql-sys:db-type-has-views? db-underlying-type))
index 9b4b85780dacada03d4ea2b717e516036deedf28..4cf7f08cddf7330b00f266200f04b9c3102b5e87 100644 (file)
       (clsql:time= add-time roll-time))
   t)
 
+
+
+
+(def-view-class datetest ()
+  ((testtime :COLUMN "testtime" :TYPE
+            clsql-sys:wall-time :DB-KIND :BASE
+            :DB-CONSTRAINTS COMMON-LISP:NIL
+            :ACCESSOR testtime :INITARG
+            :testtime :INITFORM COMMON-LISP:NIL
+            :DB-TYPE "timestamptz")))
+
+
+
+(deftest :time-test-retrieving/saving/retrieving
+    (when (or (eq :postgresql *test-database-underlying-type*)
+             (eq :postgresql-socket *test-database-underlying-type*))
+      #.(clsql-sys:locally-enable-sql-reader-syntax)
+      (unless (clsql-sys:table-exists-p "datetest")
+       (clsql-sys:create-view-from-class 'datetest))
+      (clsql-sys:delete-records :from 'datetest)
+      (let ((time (parse-timestring "2008-09-09T14:37:29.622278-04:00")))
+       (clsql-sys:update-records-from-instance
+        (make-instance 'datetest :testtime time))
+       (let ((o (first (clsql:select
+                           'datetest
+                         :limit 1 :flatp T
+                         :where [= [testtime] time] ))))
+         (assert o (o) "o shouldnt be null here (we should have just inserted)")
+         (update-records-from-instance o)
+         (update-instance-from-records o)
+         (assert (time= (testtime o) time) (time o) "Time of o: ~a should be time:~a" (testtime o) time)
+         #.(clsql-sys:locally-disable-sql-reader-syntax)
+         )
+       )
+      nil
+      )
+  nil)
+
 ))