From 7472d6a2417672a18fa9cf5ae4e3d6b7068d0267 Mon Sep 17 00:00:00 2001 From: Russ Tyndall Date: Thu, 9 Oct 2008 16:53:42 -0400 Subject: [PATCH] Tests for the previous patch (adding special time printing in postgres). 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 | 3 ++- tests/test-time.lisp | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/test-init.lisp b/tests/test-init.lisp index b0a902c..57a3cfc 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -565,7 +565,8 @@ (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)) diff --git a/tests/test-time.lisp b/tests/test-time.lisp index 9b4b857..4cf7f08 100644 --- a/tests/test-time.lisp +++ b/tests/test-time.lisp @@ -213,4 +213,42 @@ (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) + )) -- 2.34.1