Commit dac03213 authored by ryszard.szopa's avatar ryszard.szopa
Browse files

new tests for save-dao

darcs-hash:58640451ed05636056128b9c15622145b7b90a69
parent a54e173e
......@@ -141,7 +141,56 @@ metaclass set to HTML and the right connection-spec."
(is (= 17 (length (select-dao 'foo (:= 17 foo))))))
(db-test (save-dao :depends-on dao-definition-with-foreign-key)
(defdao-example baz ()
((baz :accessor baz :initarg :baz :type integer)))
(defdao-example quux ()
((baz :accessor baz :initarg :baz :type baz :foreign t)))
(let* ((baz (submarine::make-and-save 'baz :baz 1))
(quux (make-instance 'quux :baz baz)))
(finishes (save-dao quux))
(is (equal 1 (baz (baz quux))))
))
(db-test (save-dao-recursively :depends-on save-dao)
(defdao-example baz ()
((baz :accessor baz :initarg :baz :type integer)))
(defdao-example quux ()
((baz :accessor baz :initarg :baz :type baz :foreign t)))
(let* ((baz (make-instance 'baz :baz 1))
(quux (make-instance 'quux :baz baz)))
(setf (baz baz) 2)
(finishes (save-dao quux))
(is (equal 2 (baz (baz quux))))
(let ((new-quux (make-instance 'quux :id (get-id quux))))
(is (equal 2 (baz (baz new-quux)))))))
(db-test (save-dao-wrong-id :depends-on save-dao)
(defdao-example rabe ()
((rabe :accessor rabe :initarg :rabe :type integer)))
(defdao-example tike ()
((rabe :accessor rabe :initarg :rabe :type rabe :foreign t)))
(signals dao-nonexistent-id (make-instance 'rabe :id 666 :rabe 1)) )
(db-test (save-dao-wrong-id-in-reference :depends-on save-dao)
(defdao-example rabe ()
((rabe :accessor rabe :initarg :rabe :type integer)))
(defdao-example tike ()
((rabe :accessor rabe :initarg :rabe :type rabe :foreign t)))
(let* ((rabe (make-instance 'rabe :rabe 1))
(tike (make-instance 'tike :rabe rabe)))
(setf (get-id rabe) 666) ;we set id to a random number
(save-dao tike)
(is (= (rabe rabe) (rabe (rabe (make-instance 'tike :id (get-id tike))))))))
;;; Copyright (C) 2007
;;; Ryszard Szopa <ryszard.szopa@gmail.com> &
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment