Skip to content

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Aug 27, 2025

Summary

  • Move subtests in TestCursor that test specific Cursor methods into separate test functions.

Background & Motivation

Very long test functions with deeply-nested subtests are difficult to read, maintain, and run. It's better to split up some subtests into separate test functions.

Copy link
Contributor

API Change Report

No changes found!

Copy link
Contributor

mongodb-drivers-pr-bot bot commented Aug 27, 2025

🧪 Performance Results

Commit SHA: bd7c125

The following benchmark tests for version 68b223d9f4c093000717cac8 had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkMultiFindMany total_time_seconds 19.1047 1.3171 Avg: 1.1059
Med: 1.0549
Stdev: 0.1050
0.7361 2.0113
BenchmarkSmallDocInsertOne total_time_seconds -3.8070 1.1389 Avg: 1.1840
Med: 1.1849
Stdev: 0.0218
0.7359 -2.0657
BenchmarkBSONDeepDocumentDecoding total_bytes_allocated -3.2530 243667288.0000 Avg: 251860213.4194
Med: 252330328.0000
Stdev: 3023314.2474
0.7931 -2.7099
BenchmarkBSONDeepDocumentDecoding total_mem_allocs -3.1986 11219121.0000 Avg: 11589832.4194
Med: 11611115.0000
Stdev: 138499.4358
0.7903 -2.6766
BenchmarkBSONDeepDocumentDecoding total_time_seconds -1.5791 1.1803 Avg: 1.1993
Med: 1.1989
Stdev: 0.0058
0.8506 -3.2554
BenchmarkBSONFullDocumentEncoding total_time_seconds 1.5400 1.2128 Avg: 1.1944
Med: 1.1937
Stdev: 0.0082
0.7541 2.2468
BenchmarkBSONDeepDocumentDecoding allocated_bytes_per_op -0.0543 15095.0000 Avg: 15103.1935
Med: 15104.0000
Stdev: 2.3723
0.9090 -3.4538

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@matthewdale matthewdale added enhancement review-priority-low Low Priority PR for Review: within 3 business days ignore-for-release labels Aug 27, 2025
@matthewdale matthewdale marked this pull request as ready for review August 27, 2025 20:08
@Copilot Copilot AI review requested due to automatic review settings August 27, 2025 20:09
@matthewdale matthewdale requested a review from a team as a code owner August 27, 2025 20:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the TestCursor function by splitting its nested subtests into separate, independent test functions. This improves test maintainability and readability by reducing the complexity of deeply-nested test structures.

Key changes:

  • Extracted four subtests from TestCursor into standalone test functions: TestCursor_TryNext, TestCursor_RemainingBatchLength, TestCursor_All, and TestCursor_Close
  • Moved the "set batchSize" subtest to remain within the original TestCursor function
  • Relocated variable declarations to their appropriate scopes in the new test functions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


// The initial batch length should be equal to the batchSize. Do batchSize Next calls to exhaust the current
// batch and assert that no getMore was done.
assertCursorBatchLength(mt, cursor, batchSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not part of the changes in this PR but assertCursorBatchLength should call mt.Helper().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed assertCursorBatchLength because it can be condensed into a single assert call, making the test easier to read.

matthewdale and others added 11 commits August 29, 2025 14:58
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Co-authored-by: Preston Vasquez <prestonvasquez@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ignore-for-release review-priority-low Low Priority PR for Review: within 3 business days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants