Skip to content

add support for mongo driver v2. #124

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

xiaoquanidea
Copy link

add support for mongo driver v2

@xiaoquanidea
Copy link
Author

run the command make test.with_real_db, and the unit tests pass normally:
image

… handshake, ptrutil) from the MongoDB Go Driver
@xiaoquanidea xiaoquanidea requested a review from Khranovskiy July 17, 2025 02:58
// Use of this source code is governed by an MIT-style license that can be found in
// the THIRD-PARTY-NOTICES file.

package assert
Copy link
Member

Choose a reason for hiding this comment

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

Thank you very much for your work.

I see that you copy a lot of code from other packages.
Could you just import them instead of copying?
The driver is a separate module, so there should be no problem.

Copy link
Author

Choose a reason for hiding this comment

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

At first, I also wanted to write unit tests by importing the mongo-driver/v2 package, but this code is in the internal package and cannot be referenced externally. I had no choice but to use a copy-paste approach.

Copy link
Member

Choose a reason for hiding this comment

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

Could you clarify, which internal code or method do you use?

mongo/v2 required go 1.21 so I don't undrstand why do you need go 1.17 copabilities for mongo/v2

Copy link
Author

Choose a reason for hiding this comment

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

Could you clarify, which internal code or method do you use?

mongo/v2 required go 1.21 so I don't undrstand why do you need go 1.17 copabilities for mongo/v2

I copied this from https://github.com/mongodb/mongo-go-driver/tree/v2.0.0/internal. The official version is based on Go 1.18. Taking https://github.com/mongodb/mongo-go-driver/blob/v2.0.0/internal/assert/assertion_compare_go1.17_test.go as an example, the official repository has these Go files, and I brought them all over when I copied the entire folder.

Copy link
Member

Choose a reason for hiding this comment

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

I asked which methods or code lines do you use.

I see that you use mtest.
As I see there is not mtest in v2 but there is MockDeployment.

@xiaoquanidea xiaoquanidea requested a review from maranqz July 30, 2025 05:42
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.

3 participants