Skip to content

CSHARP-5582: Assert unset BulkWriteException.partialResult in CRUD prose tests #1727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ private void EnsureCanProceedNextBatch(ConnectionId connectionId, BulkWriteRawRe
{
if (bulkWriteResult.TopLevelException != null)
{
var partialResult = ToClientBulkWriteResult(bulkWriteResult);
ClientBulkWriteResult partialResult = null;
if (_writeModels.Offset != 0)
{
partialResult = ToClientBulkWriteResult(bulkWriteResult);
}

throw new ClientBulkWriteException(
connectionId,
"An error occurred during bulkWrite operation. See InnerException for more details.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public async Task MongoClient_bulkWrite_throws_if_no_operations_can_be_added_big

var bulkWriteException = exception.Should().BeOfType<ClientBulkWriteException>().Subject;
bulkWriteException.InnerException.Should().BeOfType<FormatException>();
bulkWriteException.PartialResult.Should().BeNull();
}

// https://github.com/mongodb/specifications/blob/7517681e6a3186cb7f3114314a9fe1bc3a747b9f/source/crud/tests/README.md?plain=1#L602
Expand All @@ -522,6 +523,7 @@ public async Task MongoClient_bulkWrite_throws_if_no_operations_can_be_added_big

var bulkWriteException = exception.Should().BeOfType<ClientBulkWriteException>().Subject;
bulkWriteException.InnerException.Should().BeOfType<FormatException>();
bulkWriteException.PartialResult.Should().BeNull();
}

// https://github.com/mongodb/specifications/blob/7517681e6a3186cb7f3114314a9fe1bc3a747b9f/source/crud/tests/README.md?plain=1#L647
Expand Down Expand Up @@ -560,6 +562,7 @@ public async Task MongoClient_bulkWrite_throws_if_auto_encryption_configured([Va
: Record.Exception(() => client.BulkWrite(models));

exception.Should().BeOfType<NotSupportedException>();
exception.Message.Should().Be("BulkWrite does not currently support automatic encryption.");
}

// https://github.com/mongodb/specifications/blob/d1bdb68b7b4aec9681ea56d41c8b9a6c1a97d365/source/crud/tests/README.md?plain=1#L699
Expand Down