Skip to content

Commit 385a892

Browse files
author
Ryan
committed
added unit test for x.y ensureIndex.
1 parent 6f7f9a2 commit 385a892

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/com/mongodb/DBCollectionTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public DBCollectionTest()
3333
cleanupDB = "com_mongodb_unittest_DBCollectionTest";
3434
_db = cleanupMongo.getDB( cleanupDB );
3535
}
36+
3637
@Test(groups = {"basic"})
3738
public void testMultiInsert() {
3839
DBCollection c = _db.getCollection("testmultiinsert");
@@ -177,6 +178,20 @@ public void testEnsureIndex(){
177178
assertEquals( Boolean.TRUE , c.getIndexInfo().get(1).get( "unique" ) );
178179
}
179180

181+
@Test
182+
public void testEnsureNestedIndex(){
183+
DBCollection c = _db.getCollection( "ensureNestedIndex1" );
184+
c.drop();
185+
186+
BasicDBObject newDoc = new BasicDBObject( "x", new BasicDBObject( "y", 1 ) );
187+
c.save( newDoc );
188+
189+
assertEquals( 1 , c.getIndexInfo().size() );
190+
c.ensureIndex( new BasicDBObject("x.y", 1), "nestedIdx1", false);
191+
assertEquals( 2 , c.getIndexInfo().size() );
192+
}
193+
194+
180195
@Test
181196
public void testIndexExceptions(){
182197
DBCollection c = _db.getCollection( "indexExceptions" );

0 commit comments

Comments
 (0)