add test for ensure_index with drop_dups

This commit is contained in:
Peter Olsen 2011-05-19 19:35:06 +00:00
parent 088b158ece
commit 809dcf7e17
1 changed files with 8 additions and 0 deletions

View File

@ -809,6 +809,14 @@ class TestCollection < Test::Unit::TestCase
assert_equal 1, @collection.find({:a => 1}).count assert_equal 1, @collection.find({:a => 1}).count
end end
should "drop duplicates with ensure_index and drop_dups key" do
@collection.insert({:a => 1})
@collection.insert({:a => 1})
assert_equal 2, @collection.find({:a => 1}).count
@collection.ensure_index([['a', Mongo::ASCENDING]], :unique => true, :drop_dups => true)
assert_equal 1, @collection.find({:a => 1}).count
end
should "create an index in the background" do should "create an index in the background" do
if @@version > '1.3.1' if @@version > '1.3.1'
@collection.create_index([['b', Mongo::ASCENDING]], :background => true) @collection.create_index([['b', Mongo::ASCENDING]], :background => true)