fakemongo / fongo

faked out in-memory mongo for java
Apache License 2.0
523 stars 156 forks source link

Contents of MongoBulkWriteException thrown by MongoCollection#insertMany are not correct #309

Closed mcdimus closed 7 years ago

mcdimus commented 7 years ago

The problem is when MongoCollection#insertMany is called so that unique index is violated. MongoBulkWriteException is thrown and there are two issues with that.

  1. MongoBulkWriteException.getWriteErrors() is returning List of BulkWriteErrors, the problem is that BulkWriteError always has its index equal to 0 instead of a correct one.
  2. MongoBulkWriteException.getWriteResult() always has 0 in all of its count fields despite the fact that some documents were successfully written to collection.

If I would change FongoRule to use real MongoDB, everything will work as expected.