Skip to content

Commit c849f75

Browse files
committed
Fix test that broke because server error message changed.
1 parent 5bc1291 commit c849f75

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

tests/MongoDB.Driver.Core.Tests/Core/Operations/RenameCollectionOperationTests.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,10 @@ private void EnsureCollectionDoesNotExist(CollectionNamespace collectionNamespac
225225

226226
private void EnsureCollectionExists(CollectionNamespace collectionNamespace, bool async)
227227
{
228-
try
229-
{
230-
var operation = new CreateCollectionOperation(collectionNamespace, _messageEncoderSettings);
231-
ExecuteOperation(operation, async);
232-
}
233-
catch (MongoCommandException ex)
234-
{
235-
if (ex.Message == "Command create failed: collection already exists.")
236-
{
237-
return;
238-
}
239-
throw;
240-
}
228+
var document = new BsonDocument("_id", ObjectId.GenerateNewId());
229+
var insertRequests = new[] { new InsertRequest(document) };
230+
var insertOperation = new BulkInsertOperation(collectionNamespace, insertRequests, _messageEncoderSettings);
231+
ExecuteOperation(insertOperation, async);
241232
}
242233
}
243234
}

0 commit comments

Comments
 (0)