Skip to content

Add MongoDB integration tests for all strfmt BSON types#215

Merged
fredbi merged 3 commits intomasterfrom
copilot/add-integration-tests-for-mongodb
Mar 6, 2026
Merged

Add MongoDB integration tests for all strfmt BSON types#215
fredbi merged 3 commits intomasterfrom
copilot/add-integration-tests-for-mongodb

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

  • Create integration test module with separate go.mod
  • Upgrade to mongo-driver v2 and run go mod tidy
  • Fix bson.Mbson.D type assertions for mongo-driver v2 compatibility (nested docs decode as bson.D in v2)
  • Verify tests compile correctly

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add integration test for main module against MongoDB Add MongoDB integration tests for all strfmt BSON types Mar 6, 2026
@fredbi fredbi marked this pull request as ready for review March 6, 2026 12:39
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.01%. Comparing base (8a8c741) to head (374e2c0).
⚠️ Report is 4 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #215   +/-   ##
=======================================
  Coverage   85.01%   85.01%           
=======================================
  Files          14       14           
  Lines        2015     2015           
=======================================
  Hits         1713     1713           
  Misses        218      218           
  Partials       84       84           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…orkflow

Co-authored-by: fredbi <14262513+fredbi@users.noreply.github.com>
@fredbi fredbi force-pushed the copilot/add-integration-tests-for-mongodb branch from 16bceb8 to 1eaefbd Compare March 6, 2026 18:08
@fredbi
Copy link
Member

fredbi commented Mar 6, 2026

@copilot this is rebased. Please upgrade mongo driver to v2 and go mod tidy

Co-authored-by: fredbi <14262513+fredbi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot this is rebased. Please upgrade mongo driver to v2 and go mod tidy

Done in f8f788d. Updated integration test module to go.mongodb.org/mongo-driver/v2 v2.5.0 — updated imports (v2/bson, v2/mongo, v2/mongo/options), adapted mongo.Connect call for v2 API (no context param), replaced primitive.* types with bson.*, and ran go mod tidy.

@fredbi
Copy link
Member

fredbi commented Mar 6, 2026

@copilot fixing the integration test after mongodb upgrade to v2 seems more complex than first expected. All tests fail with a message similar to:

=== RUN TestSSN
mongo_test.go:401: expected bson.M for value, got bson.D

Co-authored-by: fredbi <14262513+fredbi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot fixing the integration test after mongodb upgrade to v2 seems more complex than first expected. All tests fail with a message similar to:

=== RUN TestSSN
...

Fixed in 374e2c0. In mongo-driver v2, nested sub-documents within a decoded bson.M are returned as bson.D (ordered) instead of bson.M. Updated all type assertions for result["value"] from bson.M to bson.D in TestDate, TestDuration, TestBase64, TestULID, and the stringFormatRoundTrip helper. bson.Marshal(bson.D{...}) works the same as bson.Marshal(bson.M{...}) so the roundtrip logic is unchanged.

@fredbi fredbi merged commit 9a928ad into master Mar 6, 2026
22 checks passed
@fredbi fredbi deleted the copilot/add-integration-tests-for-mongodb branch March 6, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants