Skip to content

Commit 809dcf7

Browse files
committed
add test for ensure_index with drop_dups
1 parent 088b158 commit 809dcf7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/collection_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,14 @@ def test_ensure_index_timeout
809809
assert_equal 1, @collection.find({:a => 1}).count
810810
end
811811

812+
should "drop duplicates with ensure_index and drop_dups key" do
813+
@collection.insert({:a => 1})
814+
@collection.insert({:a => 1})
815+
assert_equal 2, @collection.find({:a => 1}).count
816+
@collection.ensure_index([['a', Mongo::ASCENDING]], :unique => true, :drop_dups => true)
817+
assert_equal 1, @collection.find({:a => 1}).count
818+
end
819+
812820
should "create an index in the background" do
813821
if @@version > '1.3.1'
814822
@collection.create_index([['b', Mongo::ASCENDING]], :background => true)

0 commit comments

Comments
 (0)