From 7227bd64361d5bcbfc502f657168759beadff373 Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Mon, 12 Sep 2011 14:49:28 +0400 Subject: [PATCH] Add one more test that demonstrates monger.collection/update behavior with the $set operator --- test/monger/test/collection.clj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/monger/test/collection.clj b/test/monger/test/collection.clj index a2d398f..0b79714 100644 --- a/test/monger/test/collection.clj +++ b/test/monger/test/collection.clj @@ -345,6 +345,18 @@ (is (= 1 (monger.collection/count collection { :name "Alan", :age 40 }))))) +(deftest set-an-attribute-on-existing-document-using-update + (let [collection "people" + doc-id (monger.util/object-id) + document { :_id doc-id, :name "Joe", :age 30 }] + (is (monger.result/ok? (monger.collection/insert "people" document))) + (is (= 1 (monger.collection/count collection))) + (is (= 0 (monger.collection/count collection { :has_kids true }))) + (monger.collection/update collection { :_id doc-id } { "$set" { :has_kids true } }) + (is (= 1 (monger.collection/count collection { :has_kids true }))))) + + + (deftest upsert-a-document (let [collection "libraries" doc-id (monger.util/random-uuid)