File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,16 @@ func Value(opts Options, key string) any {
30
30
}
31
31
return nil
32
32
}
33
+
34
+ // Equal compares two Options instances for equality.
35
+ func Equal (opts1 , opts2 Options ) bool {
36
+ if len (opts1 .values ) != len (opts2 .values ) {
37
+ return false
38
+ }
39
+ for key , val1 := range opts1 .values {
40
+ if val2 , ok := opts2 .values [key ]; ! ok || val1 != val2 {
41
+ return false
42
+ }
43
+ }
44
+ return true
45
+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
27
27
"go.mongodb.org/mongo-driver/v2/event"
28
28
"go.mongodb.org/mongo-driver/v2/internal/assert"
29
29
"go.mongodb.org/mongo-driver/v2/internal/httputil"
30
+ "go.mongodb.org/mongo-driver/v2/internal/options"
30
31
"go.mongodb.org/mongo-driver/v2/internal/ptrutil"
31
32
"go.mongodb.org/mongo-driver/v2/mongo/readconcern"
32
33
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
@@ -156,6 +157,7 @@ func TestClientOptions(t *testing.T) {
156
157
cmp .Comparer (func (r1 , r2 * bson.Registry ) bool { return r1 == r2 }),
157
158
cmp .Comparer (func (cfg1 , cfg2 * tls.Config ) bool { return cfg1 == cfg2 }),
158
159
cmp .Comparer (func (fp1 , fp2 * event.PoolMonitor ) bool { return fp1 == fp2 }),
160
+ cmp .Comparer (options .Equal ),
159
161
cmp .AllowUnexported (ClientOptions {}),
160
162
cmpopts .IgnoreFields (http.Client {}, "Transport" ),
161
163
); diff != "" {
You can’t perform that action at this time.
0 commit comments