From 1011d4f44384e10f45ea0268e5c7fc759f417d3e Mon Sep 17 00:00:00 2001 From: Holger Schauer Date: Thu, 3 Mar 2011 11:24:10 +0100 Subject: [PATCH] ds-artists: new test dataset ds-artists. clsql-tests.asd: add new filee ds-artists. test-oodml: Add two simple tests in tests-oodml for autoincrement behaviour. --- clsql-tests.asd | 3 ++- tests/ds-artists.lisp | 36 ++++++++++++++++++++++++++++++++++++ tests/test-init.lisp | 5 +++-- tests/test-oodml.lisp | 10 ++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/ds-artists.lisp diff --git a/clsql-tests.asd b/clsql-tests.asd index a7c7c68..400e43d 100644 --- a/clsql-tests.asd +++ b/clsql-tests.asd @@ -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 index 0000000..8fe86d2 --- /dev/null +++ b/tests/ds-artists.lisp @@ -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) diff --git a/tests/test-init.lisp b/tests/test-init.lisp index c11a273..3efa6d6 100644 --- a/tests/test-init.lisp +++ b/tests/test-init.lisp @@ -294,12 +294,13 @@ (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)) diff --git a/tests/test-oodml.lisp b/tests/test-oodml.lisp index dadbfcb..d1c933a 100644 --- a/tests/test-oodml.lisp +++ b/tests/test-oodml.lisp @@ -211,6 +211,11 @@ (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* @@ -614,6 +619,11 @@ ((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 -- 2.34.1