Add a test that harnesses monger.collection/save with new DBObjects (useful for obtaining of the generated _id)
This commit is contained in:
parent
be1355b5b9
commit
adfa422a51
1 changed files with 12 additions and 2 deletions
|
|
@ -29,7 +29,7 @@
|
||||||
(is (monger.result/ok? (monger.collection/insert "people" doc WriteConcern/SAFE)))
|
(is (monger.result/ok? (monger.collection/insert "people" doc WriteConcern/SAFE)))
|
||||||
(is (= 1 (monger.collection/count collection)))))
|
(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"
|
(let [collection "people"
|
||||||
doc (monger.convertion/to-db-object { :name "Joe", :age 30 })]
|
doc (monger.convertion/to-db-object { :name "Joe", :age 30 })]
|
||||||
(monger.collection/remove collection)
|
(monger.collection/remove collection)
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; update
|
;; update, save
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(deftest update-document-by-id-without-upsert
|
(deftest update-document-by-id-without-upsert
|
||||||
|
|
@ -254,6 +254,16 @@
|
||||||
(is (= 1 (monger.collection/count collection)))))
|
(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
|
(deftest update-an-existing-document-using-save
|
||||||
(let [collection "people"
|
(let [collection "people"
|
||||||
doc-id "people-1"
|
doc-id "people-1"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue