[clouchdb-cvs] CVS clouchdb/src
peddy
peddy at common-lisp.net
Sat Jul 11 23:34:06 UTC 2009
Update of /project/clouchdb/cvsroot/clouchdb/src
In directory cl-net:/tmp/cvs-serv28650
Modified Files:
tests.lisp
Log Message:
- Renamed *db* to *couchdb* to make it easier to import this value in other apps
- Updated copy-document and other functions to allow documents to be
specified by id or by document
- Added more test cases
--- /project/clouchdb/cvsroot/clouchdb/src/tests.lisp 2009/07/07 19:50:20 1.20
+++ /project/clouchdb/cvsroot/clouchdb/src/tests.lisp 2009/07/11 23:34:06 1.21
@@ -283,7 +283,7 @@
(addtest (clouchdb-db-admin-tests)
(:documentation "Ensure get-db-info reports non-existant databases")
db-non-existance-test
- (let ((*db* (make-db :name (create-temp-db-name))))
+ (let ((*couchdb* (make-db :name (create-temp-db-name))))
(ensure-same "not_found" (document-property :|error|
(get-db-info)))
(ensure-same "no_db_file" (document-property :|reason| (get-db-info)))))
@@ -293,16 +293,16 @@
db-creation-test
(with-temp-db
(ensure-same (document-property :|db_name| (get-db-info))
- (db-name *db*))
- (ensure-same (document-property :|db_name| (get-db-info :db *db*))
- (db-name *db*))
- (ensure-same 0 (document-property :|doc_count| (get-db-info :db *db*)))
- (ensure-same 0 (document-property :|update_seq| (get-db-info :db *db*)))))
+ (db-name *couchdb*))
+ (ensure-same (document-property :|db_name| (get-db-info :db *couchdb*))
+ (db-name *couchdb*))
+ (ensure-same 0 (document-property :|doc_count| (get-db-info :db *couchdb*)))
+ (ensure-same 0 (document-property :|update_seq| (get-db-info :db *couchdb*)))))
(addtest (clouchdb-db-admin-tests)
(:documentation "Make sure deleting a nonexistant db generates an error")
db-delete-non-existant-db
- (ensure-condition 'db-does-not-exist (delete-db :db-name (create-temp-db-name))))
+ (ensure-condition 'db-does-not-exist (delete-db :db (create-temp-db-name))))
(addtest (clouchdb-db-admin-tests)
(:documentation "Make sure deleting a nonexistant db error is ignoreable")
@@ -310,7 +310,7 @@
(ensure
(document-property
:|error|
- (delete-db :if-missing :ignore :db-name (create-temp-db-name)))))
+ (delete-db :if-missing :ignore :db (create-temp-db-name)))))
(addtest (clouchdb-db-admin-tests)
(:documentation "Creating a db that already exists is an error")
@@ -324,7 +324,7 @@
db-create-existant-db-name
(ensure-condition 'db-already-exists
(with-temp-db
- (db-name (create-db :db-name (db-name *db*))))))
+ (db-name (create-db :db (db-name *couchdb*))))))
(addtest (clouchdb-db-admin-tests)
(:documentation "Ignore the duplicate db create error")
@@ -353,7 +353,7 @@
(deftestsuite clouchdb-doc-api-tests ()
()
(:dynamic-variables
- (*db* (make-db :db *db*)))
+ (*couchdb* (make-db :db *couchdb*)))
(:setup
(set-connection :db (create-temp-db)))
(:teardown
@@ -363,7 +363,7 @@
(:documentation "Ensures the temporary db for these tests is succesfully created.")
empty-test
(ensure-same (document-property :|db_name| (get-db-info))
- (db-name *db*)))
+ (db-name *couchdb*)))
(addtest (clouchdb-doc-api-tests)
(:documentation "Create a document with create-document")
@@ -417,6 +417,54 @@
(length (document-property :|_revs_info| docinf))))))
(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, creating destination with source ID")
+ copy-document-create-dest-id
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (copy-document "source" "dest")))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, creating destination with source document")
+ copy-document-create-dest-doc
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (copy-document (get-document "source") "dest")))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, overwrite destination by specifying revision")
+ copy-document-overwrite-dest-1
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (create-document '((:dest . "data")) :id "dest"))
+ (ensure (copy-document "source" "dest"
+ :revision (document-revision (get-document "dest")))))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, overwrite destination by specifying current revision")
+ copy-document-overwrite-dest-2
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (create-document '((:dest . "data")) :id "dest"))
+ (ensure (copy-document "source" "dest" :revision :current)))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, overwrite destination by specifying dest document")
+ copy-document-overwrite-dest-3
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (create-document '((:dest . "data")) :id "dest"))
+ (ensure (copy-document "source" (get-document "dest"))))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, overwrite destination by specifying current revision")
+ copy-document-overwrite-revision-conflict
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (create-document '((:dest . "data")) :id "dest"))
+ (ensure-condition 'id-or-revision-conflict (copy-document "source" "dest")))
+
+(addtest (clouchdb-doc-api-tests)
+ (:documentation "Copy document, overwrite destination by specifying current revision")
+ copy-document-source-id-missing
+ (ensure (create-document '((:source . "data")) :id "source"))
+ (ensure (create-document '((:dest . "data")) :id "dest"))
+ (ensure-condition 'doc-error (copy-document "doesnotexist" "dest")))
+
+(addtest (clouchdb-doc-api-tests)
(:documentation "Delete a document by ID")
delete-document-by-id
(ensure (document-property :|ok| (create-document '((:a "test")) :id "specified")))
@@ -606,7 +654,10 @@
(ensure (document-property
:|ok|
(with-attachment (stream "doc" "tests.lisp")
- (add-attachment "doc2" stream :name "tests2.lisp")))))
+ (add-attachment "doc2" stream :name "tests2.lisp"))))
+ (let ((attachments (attachment-list "doc2")))
+ (ensure-same 1 (length attachments))
+ (ensure (find :|tests2.lisp| attachments :key #'car))))
;;
;; Replication Tests.
@@ -615,7 +666,7 @@
(deftestsuite clouchdb-replication-tests ()
()
(:dynamic-variables
- (*db* (make-db)))
+ (*couchdb* (make-db)))
(:setup
(progn
(set-connection :db (create-temp-db))
@@ -628,19 +679,19 @@
(addtest (clouchdb-replication-tests)
(:documentation "test local replication of current db to new db using string identifier")
db-replicate-local-1
- (let ((db *db*))
+ (let ((db *couchdb*))
(with-temp-db
- (let ((target *db*)
- (*db* db))
+ (let ((target *couchdb*)
+ (*couchdb* db))
(ensure (document-property :|ok| (replicate target)))))))
(addtest (clouchdb-replication-tests)
(:documentation "test local replication of current db to new db using string identifiers")
db-replicate-local-2
(ensure (document-property :|ok|
- (let ((source *db*))
+ (let ((source *couchdb*))
(with-temp-db
- (let ((target *db*))
+ (let ((target *couchdb*))
(replicate (db-name target)
:source (db-name source))))))))
@@ -649,9 +700,9 @@
"test local and remote replication of current db to new db using db and string identifiers")
db-replicate-mixed-1
(ensure (document-property :|ok|
- (let ((source *db*))
+ (let ((source *couchdb*))
(with-temp-db
- (let ((target *db*))
+ (let ((target *couchdb*))
(replicate target
:source (db-name source))))))))
@@ -660,9 +711,9 @@
"test remote API replication of current db to new db using database identifiers")
db-replicate-dbs
(ensure (document-property :|ok|
- (let ((source *db*))
+ (let ((source *couchdb*))
(with-temp-db
- (let ((target *db*))
+ (let ((target *couchdb*))
(replicate target :source source)))))))
;;
@@ -672,7 +723,7 @@
(deftestsuite clouchdb-view-tests ()
()
(:dynamic-variables
- (*db* (make-db :db *db*)))
+ (*couchdb* (make-db :db *couchdb*)))
(:setup
(progn
(set-connection :db (create-temp-db))
@@ -828,9 +879,6 @@
:end-key '("boston" "d"))))))
-
-
-
(defun run-all-tests ()
(dolist (suite '(clouchdb-general-tests
clouchdb-db-admin-tests
More information about the clouchdb-cvs
mailing list