From adfa422a515d61154b615b4e02a4a9f242912284 Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Fri, 2 Sep 2011 03:19:35 +0400 Subject: [PATCH] Add a test that harnesses monger.collection/save with new DBObjects (useful for obtaining of the generated _id) --- test/monger/test/collection.clj | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/monger/test/collection.clj b/test/monger/test/collection.clj index cb49017..36355d9 100644 --- a/test/monger/test/collection.clj +++ b/test/monger/test/collection.clj @@ -29,7 +29,7 @@ (is (monger.result/ok? (monger.collection/insert "people" doc WriteConcern/SAFE))) (is (= 1 (monger.collection/count collection))))) -(deftest insert-a-basic-db-boject-without-id-and-with-default-write-concern +(deftest insert-a-basic-db-object-without-id-and-with-default-write-concern (let [collection "people" doc (monger.convertion/to-db-object { :name "Joe", :age 30 })] (monger.collection/remove collection) @@ -214,7 +214,7 @@ ;; -;; update +;; update, save ;; (deftest update-document-by-id-without-upsert @@ -254,6 +254,16 @@ (is (= 1 (monger.collection/count collection))))) +(deftest save-a-new-basic-db-object + (let [collection "people" + doc (monger.convertion/to-db-object { :name "Joe", :age 30 })] + (monger.collection/remove collection) + (is (nil? (.get doc "_id"))) + (monger.collection/save "people" doc) + (is (not (nil? (.get doc "_id")))))) + + + (deftest update-an-existing-document-using-save (let [collection "people" doc-id "people-1"