One more test case
This commit is contained in:
parent
0db4bc6e11
commit
ca67d9f4cb
1 changed files with 9 additions and 1 deletions
|
|
@ -320,12 +320,20 @@
|
||||||
|
|
||||||
|
|
||||||
(deftest find-and-modify-upsert-a-document
|
(deftest find-and-modify-upsert-a-document
|
||||||
|
(testing "case 1"
|
||||||
(let [coll "docs"
|
(let [coll "docs"
|
||||||
oid (ObjectId.)
|
oid (ObjectId.)
|
||||||
doc {:_id oid :name "Sophie Bangs" :level 42}]
|
doc {:_id oid :name "Sophie Bangs" :level 42}]
|
||||||
(let [res (mgcol/find-and-modify coll doc doc :upsert true)]
|
(let [res (mgcol/find-and-modify coll doc doc :upsert true)]
|
||||||
(is (empty? res))
|
(is (empty? res))
|
||||||
(is (select-keys (mgcol/find-map-by-id coll oid) [:name :level]) (dissoc doc :_id)))))
|
(is (select-keys (mgcol/find-map-by-id coll oid) [:name :level]) (dissoc doc :_id)))))
|
||||||
|
(testing "case 2"
|
||||||
|
(let [coll "docs"
|
||||||
|
query {:name "Sophie Bangs"}
|
||||||
|
doc (merge query {:level 42})]
|
||||||
|
(let [res (mgcol/find-and-modify coll query doc :upsert true :return-new true)]
|
||||||
|
(is (:_id res))
|
||||||
|
(is (select-keys (mgcol/find-map-by-id coll (:_id res)) [:name :level]) doc)))))
|
||||||
|
|
||||||
|
|
||||||
(deftest find-and-modify-after-sort
|
(deftest find-and-modify-after-sort
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue