-
Notifications
You must be signed in to change notification settings - Fork 919
GODRIVER-3544, GODRIVER-3653 Allow Client to Send Client Metadata On-Demand #2197
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
matthewdale
merged 15 commits into
mongodb:master
from
prestonvasquez:feature/godriver-3544-metadata-on-demand
Oct 17, 2025
+1,737
−329
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6590f6e
Allow appending client metadata
prestonvasquez 751104f
Finish prose tests
prestonvasquez 9373c48
Use BSON document literals to define the expected metadata documents.
matthewdale 8d6b75d
Use statically-defined expected metadata documents for all tests.
matthewdale f0bc695
Merge branch 'master' into feature/godriver-3544-metadata-on-demand
matthewdale bc9a413
Fix TestAuthenticateToAnything and reduce calls to atomic.Pointer.Load
matthewdale 74be46f
Move assert.EqualBSON to the assertbson package and use it instead of…
matthewdale 8b483fd
Fix appending client metadata for authenticated handshakes.
matthewdale b9d57dd
Merge branch 'master' into feature/godriver-3544-metadata-on-demand
matthewdale 2cce6d6
Fix app name test.
matthewdale 551ff2e
Fix LB handshake test and PR feedback.
matthewdale 9fa6096
Fix AppendDriverInfo comment.
matthewdale 0785b0d
Fix non-LB handshake test.
matthewdale 11282cd
Update internal/assert/assertbson/assertbson_test.go
matthewdale 11797dc
Add test cases for assertbson.EqualValue
matthewdale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Copyright (C) MongoDB, Inc. 2025-present. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. You may obtain | ||
| // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| package assertbson | ||
|
|
||
| import ( | ||
| "go.mongodb.org/mongo-driver/v2/bson" | ||
| "go.mongodb.org/mongo-driver/v2/internal/assert" | ||
| "go.mongodb.org/mongo-driver/v2/x/bsonx/bsoncore" | ||
| ) | ||
|
|
||
| type tHelper interface { | ||
| Helper() | ||
| } | ||
|
|
||
| // EqualDocument asserts that the expected and actual BSON documents are equal. | ||
| // If the documents are not equal, it prints both the binary diff and Extended | ||
| // JSON representation of the BSON documents. | ||
| func EqualDocument(t assert.TestingT, expected, actual []byte) bool { | ||
| if h, ok := t.(tHelper); ok { | ||
| h.Helper() | ||
| } | ||
|
|
||
| return assert.Equal(t, | ||
| expected, | ||
| actual, | ||
| `expected and actual BSON documents do not match | ||
| As Extended JSON: | ||
| Expected: %s | ||
| Actual : %s`, | ||
| bson.Raw(expected), | ||
| bson.Raw(actual)) | ||
| } | ||
|
|
||
| // EqualValue asserts that the expected and actual BSON values are equal. If the | ||
| // values are not equal, it prints both the binary diff and Extended JSON | ||
| // representation of the BSON values. | ||
| func EqualValue[T bson.RawValue | bsoncore.Value](t assert.TestingT, expected, actual T) bool { | ||
| if h, ok := t.(tHelper); ok { | ||
| h.Helper() | ||
| } | ||
|
|
||
| return assert.Equal(t, | ||
| expected, | ||
| actual, | ||
| `expected and actual BSON values do not match | ||
| As Extended JSON: | ||
| Expected: %s | ||
| Actual : %s`, | ||
| expected, | ||
| actual) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright (C) MongoDB, Inc. 2025-present. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| // not use this file except in compliance with the License. You may obtain | ||
| // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| package assertbson | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "go.mongodb.org/mongo-driver/v2/bson" | ||
| ) | ||
|
|
||
| func TestEqualDocument(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| testCases := []struct { | ||
| name string | ||
| expected []byte | ||
| actual []byte | ||
| want bool | ||
| }{ | ||
| { | ||
| name: "equal bson.Raw", | ||
| expected: bson.Raw{5, 0, 0, 0, 0}, | ||
| actual: bson.Raw{5, 0, 0, 0, 0}, | ||
| want: true, | ||
| }, | ||
| { | ||
| name: "different bson.Raw", | ||
| expected: bson.Raw{8, 0, 0, 0, 10, 120, 0, 0}, | ||
| actual: bson.Raw{5, 0, 0, 0, 0}, | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "invalid bson.Raw", | ||
| expected: bson.Raw{99, 99, 99, 99}, | ||
| actual: bson.Raw{5, 0, 0, 0, 0}, | ||
| want: false, | ||
| }, | ||
| { | ||
| name: "nil bson.Raw", | ||
| expected: bson.Raw(nil), | ||
| actual: bson.Raw(nil), | ||
| want: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| tc := tc // Capture range variable. | ||
|
|
||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| got := EqualDocument(new(testing.T), tc.expected, tc.actual) | ||
| if got != tc.want { | ||
| t.Errorf("EqualBSON(%#v, %#v) = %v, want %v", tc.expected, tc.actual, got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.