ds-artists: new test dataset ds-artists. clsql-tests.asd: add new filee ds-artists...
authorHolger Schauer <Holger.Schauer@gmx.de>
Thu, 3 Mar 2011 10:24:10 +0000 (11:24 +0100)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 30 Mar 2011 00:20:06 +0000 (18:20 -0600)
clsql-tests.asd
tests/ds-artists.lisp [new file with mode: 0644]
tests/test-init.lisp
tests/test-oodml.lisp

index a7c7c68430437ef7e1c91d656f367ccbf225b291..400e43d85221663d127c345a286272d3c6133783 100644 (file)
@@ -38,6 +38,7 @@
                           (:file "datasets")
                           (:file "ds-employees")
                           (:file "ds-nodes")
+                          (:file "ds-artists")
                           (:file "benchmarks")
                           (:file "test-internal")
                           (:file "test-basic")
@@ -48,7 +49,7 @@
                           (:file "test-ooddl")
                           (:file "test-oodml")
                           (:file "test-syntax")
-                           #-uffi:no-i18n (:file "test-i18n")
+                           #-uffi:no-i18n (:file "test-i18n")
                            ))))
 
 (defmethod perform ((o test-op) (c (eql (find-system 'clsql-tests))))
diff --git a/tests/ds-artists.lisp b/tests/ds-artists.lisp
new file mode 100644 (file)
index 0000000..8fe86d2
--- /dev/null
@@ -0,0 +1,36 @@
+(in-package #:clsql-tests)
+
+#.(clsql:locally-enable-sql-reader-syntax)
+
+(defparameter artist1 nil)
+
+(def-view-class artist ()
+  ((artist_id :accessor artist_id :initarg :id
+             :type integer :db-kind :key :db-constraints (:not-null :auto-increment)
+             :autoincrement-sequence 'artist_artist_id_seq)
+   (name :accessor name :initarg :name :type (varchar 20))))
+
+(defun initialize-ds-artists ()
+   ;   (start-sql-recording :type :both)
+   ;   (let ((*backend-warning-behavior*
+   ;          (if (member *test-database-type* '(:postgresql :postgresql-socket))
+   ;              :ignore
+   ;        :warn)))
+  (mapc #'clsql:create-view-from-class
+         '(artist))
+
+  (setq *test-start-utime* (get-universal-time))
+  (let* ((*db-auto-sync* nil))
+    (setf  artist1 (make-instance 'artist
+                                 :name "Mogwai"))))
+
+(def-dataset *ds-artists*
+  (:setup initialize-ds-artists)
+  (:cleanup (lambda ()
+             (mapc #'clsql-sys:drop-view-from-class
+                   '(artist))
+             (ignore-errors
+               (mapc #'clsql-sys:drop-sequence
+                     (list "artist_artist_id_seq"))))))
+
+#.(clsql:restore-sql-reader-syntax-state)
index c11a273155d013ed056b43fdef5628d0eb087a43..3efa6d62d193130c0431a0142afb8ab1796a7123 100644 (file)
                (clsql-sys:in test :oodml/select/12 :oodml/select/13 :oodml/select/14
                              :oodml/select/15 :oodml/select/16 :oodml/select/17
                              :oodml/select/18 :oodml/select/19 :oodml/select/20
-                             :oodml/select/21 :oodml/select/22
+                             :oodml/select/21 :oodml/select/22 :oodml/select/23
                              :oodml/update-records/4 :oodml/update-records/4-slots
                              :oodml/update-records/5 :oodml/update-records/5-slots
                              :oodml/update-records/6 :oodml/update-records/7
                              :oodml/update-records/8 :oodml/update-records/9
-                             :oodml/update-records/9-slots :oodml/update-instance/3
+                             :oodml/update-records/9-slots :oodml/update-records/10
+                             :oodml/update-records/11 :oodml/update-instance/3
                              :oodml/update-instance/4 :oodml/update-instance/5
                              :oodml/update-instance/6 :oodml/update-instance/7
                              :oodml/db-auto-sync/3 :oodml/db-auto-sync/4))
index dadbfcbe6d542d753d7b20c80c21f562b5d22a30..d1c933a432d75c8340b047651fbe092590457efa 100644 (file)
          (slot-value a 'loc))))
   10 10 "subloc-1" "a subloc")
 
+(deftest :oodml/select/23
+    (with-dataset *ds-artists*
+      (length (clsql:select 'artist :flatp t :caching nil)))
+  0)
+
 ;; test retrieval is deferred
 (deftest :oodm/retrieval/1
     (with-dataset *ds-employees*
   ((42.0d0))
   ((24.13d0)))
 
+(deftest :oodml/update-records/11
+    (with-dataset *ds-artists*
+      (clsql:update-records-from-instance artist1)
+      (list (name artist1) (artist_id artist1)))
+  ("Mogwai" 1))
 
 ;; tests update-instance-from-records
 (deftest :oodml/update-instance/1