From: Nathan Bird Date: Mon, 11 Jan 2010 19:20:52 +0000 (-0500) Subject: Adding 3 new tests that show the update-record-from-slots function is awry with the... X-Git-Tag: v4.3.0^2~12 X-Git-Url: http://git.kpe.io/?p=clsql.git;a=commitdiff_plain;h=ef14ad12b16560c41609086cfba2ed15fef64061 Adding 3 new tests that show the update-record-from-slots function is awry with the normalization code. --- diff --git a/tests/test-oodml.lisp b/tests/test-oodml.lisp index 4eb624c..5d6b14b 100644 --- a/tests/test-oodml.lisp +++ b/tests/test-oodml.lisp @@ -390,6 +390,37 @@ "1 Altered title" "1 Bare node") + (deftest :oodml/update-records/4-slots ;just like 4, but use slots fns. + (flet ((print-fresh-setting () + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (format nil "~a ~a ~a" + (slot-value node 'setting-id) + (slot-value node 'title) + (slot-value node 'vars))))) + (values + (print-fresh-setting) + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (setf (slot-value node 'title) "Altered title") + (setf (slot-value node 'vars) "Altered vars") + (clsql-sys:update-record-from-slot node 'title) + (clsql-sys:update-record-from-slot node 'vars) + (print-fresh-setting)) + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (setf (slot-value node 'title) "Setting2") + (setf (slot-value node 'vars) "var 2") + (clsql:update-records-from-instance node) + (clsql-sys:update-record-from-slots node '(vars title)) + (print-fresh-setting)))) + "3 Setting2 var 2" + "3 Altered title Altered vars" + "3 Setting2 var 2") + (deftest :oodml/update-records/5 (flet ((print-fresh-setting () (let ((node (car (clsql:select 'setting @@ -419,6 +450,36 @@ "3 Altered title Altered vars" "3 Setting2 var 2") + (deftest :oodml/update-records/5-slots + (flet ((print-fresh-setting () + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (format nil "~a ~a ~a" + (slot-value node 'setting-id) + (slot-value node 'title) + (slot-value node 'vars))))) + (values + (print-fresh-setting) + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (setf (slot-value node 'title) "Altered title") + (setf (slot-value node 'vars) "Altered vars") + (clsql-sys:update-record-from-slot node 'title) + (clsql-sys:update-record-from-slot node 'vars) + (print-fresh-setting)) + (let ((node (car (clsql:select 'setting + :where [= 3 [slot-value 'setting 'setting-id]] + :flatp t :caching nil)))) + (setf (slot-value node 'title) "Setting2") + (setf (slot-value node 'vars) "var 2") + (clsql-sys:update-record-from-slots node '(title vars)) + (print-fresh-setting)))) + "3 Setting2 var 2" + "3 Altered title Altered vars" + "3 Setting2 var 2") + (deftest :oodml/update-records/6 (flet ((print-fresh-setting () (let ((node (car (clsql:select 'setting @@ -548,6 +609,37 @@ "10 Altered subloc title Altered loc" "10 subloc-1 a subloc") + (deftest :oodml/update-records/9-slots ;like 9, but use slots fns. + (flet ((print-fresh-subloc () + (let ((sl (car (clsql:select 'subloc + :where [= 10 [slot-value 'subloc 'subloc-id]] + :flatp t :caching nil)))) + (format nil "~a ~a ~a" + (slot-value sl 'subloc-id) + (slot-value sl 'title) + (slot-value sl 'loc))))) + (values + (print-fresh-subloc) + (let ((sl (car (clsql:select 'subloc + :where [= 10 [slot-value 'subloc 'subloc-id]] + :flatp t :caching nil)))) + (setf (slot-value sl 'title) "Altered subloc title") + (setf (slot-value sl 'loc) "Altered loc") + (clsql:update-record-from-slot sl 'title) + (clsql:update-record-from-slot sl 'loc) + (print-fresh-subloc)) + (let ((sl (car (clsql:select 'subloc + :where [= 10 [slot-value 'subloc 'subloc-id]] + :flatp t :caching nil)))) + (setf (slot-value sl 'title) "subloc-1") + (setf (slot-value sl 'loc) "a subloc") + (clsql:update-record-from-slot sl '(title loc)) + (print-fresh-subloc)))) + "10 subloc-1 a subloc" + "10 Altered subloc title Altered loc" + "10 subloc-1 a subloc") + + ;; tests update-instance-from-records (deftest :oodml/update-instance/1 (values