[claw-cvs] r107 - trunk/main/claw-demo/test/backend

achiumenti at common-lisp.net achiumenti at common-lisp.net
Wed Oct 1 12:02:35 UTC 2008


Author: achiumenti
Date: Wed Oct  1 08:02:30 2008
New Revision: 107

Modified:
   trunk/main/claw-demo/test/backend/tests.lisp
Log:
several bugfixes and enhancements

Modified: trunk/main/claw-demo/test/backend/tests.lisp
==============================================================================
--- trunk/main/claw-demo/test/backend/tests.lisp	(original)
+++ trunk/main/claw-demo/test/backend/tests.lisp	Wed Oct  1 08:02:30 2008
@@ -189,6 +189,43 @@
                                      :roles (list admin-role user-role)))
       (lift:ensure (find-user-by-name "admin"))))
 
+(lift:addtest (claw-demo-backend-testsuite)
+              find-users
+              (let ((admin-role (make-instance 'role :name "administrator"))
+                    (user-role (make-instance 'role :name "user")))
+                (update-db-item admin-role)
+                (update-db-item user-role)
+                (update-db-item (make-instance 'user :firstname "Andrea"
+                                               :surname "Chiumenti"
+                                               :username "admin"
+                                               :password "admin"
+                                               :email "admin at new.com"
+                                               :roles (list admin-role user-role)))
+                (lift:ensure (find-users :role-names '("administrator")))))
+
+(locally-enable-sql-reader-syntax)
+(lift:addtest (claw-demo-backend-testsuite)
+              test-join
+              (let ((admin-role (make-instance 'role :name "administrator"))
+                    (user-role (make-instance 'role :name "user")))
+                (update-db-item admin-role)
+                (update-db-item user-role)
+                (update-db-item (make-instance 'user :firstname "Andrea"
+                                               :surname "Chiumenti"
+                                               :username "admin"
+                                               :password "admin"
+                                               :email "admin at new.com"
+                                               :roles (list admin-role user-role)))
+                (lift:ensure (= (length (select 'user
+                                     :from [left-join [left-join [users] [users-roles] [= [slot-value 'user 'id] [slot-value 'user-role 'user-id] ] ] [roles] [= [slot-value 'user-role 'role-id] [slot-value 'role 'id]]]
+                                     :where [and [= [slot-value 'user 'firstname] "Andrea" ]  [= [slot-value 'role 'name] "administrator" ]]
+                                     :flatp t)) 1))
+                (lift:ensure (= (length (select 'user
+                                     :from [left-join [left-join [users] [users-roles] [= [slot-value 'user 'id] [slot-value 'user-role 'user-id] ] ] [roles] [= [slot-value 'user-role 'role-id] [slot-value 'role 'id]]]
+                                     :where [and [= [slot-value 'user 'firstname] "Andreax" ]  [= [slot-value 'role 'name] "administrator" ]]
+                                     :flatp t)) 0))))
+(locally-disable-sql-reader-syntax)
+
   (lift:addtest (claw-demo-backend-testsuite)
     like-operation
     (let ((admin-role (make-instance 'role :name "administrator"))
@@ -204,6 +241,22 @@
       (lift:ensure (find-vo 'user :where (like-operation 'username "*n\\&1")))
       (lift:ensure-null (find-vo 'user :where (like-operation 'username "*n\\&")))))
 
+(lift:addtest (claw-demo-backend-testsuite)
+    find-users
+    (let ((admin-role (make-instance 'role :name "administrator"))
+          (user-role (make-instance 'role :name "user")))
+      (update-db-item admin-role)
+      (update-db-item user-role)
+      (update-db-item (make-instance 'user :firstname "Andrea"
+                                     :surname "Chiumenti"
+                                     :username "admin\\&1"
+                                     :password "admin"
+                                     :email "admin at new.com"
+                                     :roles (list admin-role user-role)))
+      (lift:ensure (find-users :firstname "*" :role-names '("administrator")))
+      (lift:ensure-null (find-users :firstname "*" :role-names '("administratorxx")))
+      (lift:ensure-null (find-users :firstname "xxx"))))
+
 
   (lift:addtest (claw-demo-backend-testsuite)
     find-customers



More information about the Claw-cvs mailing list