[rucksack-cvs] CVS rucksack/tests

alemmens alemmens at common-lisp.net
Thu Jan 24 12:39:45 UTC 2008


Update of /project/rucksack/cvsroot/rucksack/tests
In directory clnet:/tmp/cvs-serv24508

Modified Files:
	unit-tests.lisp 
Log Message:
Add a test to verify that throwing an error inside a with-transaction form
causes a transaction rollback.

--- /project/rucksack/cvsroot/rucksack/tests/unit-tests.lisp	2008/01/23 15:46:31	1.1
+++ /project/rucksack/cvsroot/rucksack/tests/unit-tests.lisp	2008/01/24 12:39:45	1.2
@@ -244,5 +244,18 @@
       (abort)))
   (with-rucksack-and-transaction ()
     (let ((pc (car (rucksack-roots rs))))
+      (assert-equal 1 (p-car pc))))
+  ;; Test that transactions are also rolled back when we throw an
+  ;; error inside the body of a WITH-TRANSACTION form.
+  (assert-error 'error
+                (with-rucksack-and-transaction ()
+                  (let ((pc (first (rucksack-roots rs))))
+                    (setf (p-car pc) 5)
+                    ;; Abort the transaction by causing an error.
+                    (error "Something went wrong"))))
+  (with-rucksack-and-transaction ()
+    ;; Verify that the error caused a transaction rollback.
+    (let ((pc (car (rucksack-roots rs))))
       (assert-equal 1 (p-car pc)))))
 
+




More information about the rucksack-cvs mailing list