Adding 3 new tests that show the update-record-from-slots function is awry with the...
authorNathan Bird <nathan@acceleration.net>
Mon, 11 Jan 2010 19:20:52 +0000 (14:20 -0500)
committerNathan Bird <nathan@acceleration.net>
Mon, 18 Jan 2010 18:08:01 +0000 (13:08 -0500)
tests/test-oodml.lisp

index 4eb624cc0bc35a969924c594d64fa30b51ccab6c..5d6b14bc635f5b57d283d9909e90b9b643d0b9fc 100644 (file)
           "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
           "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
           "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