Skip to content

Commit 5ad38c2

Browse files
committed
fix test
1 parent 81b9815 commit 5ad38c2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

internal/options/options.go

+13
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,16 @@ func Value(opts Options, key string) any {
3030
}
3131
return nil
3232
}
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+
}

mongo/options/clientoptions_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"go.mongodb.org/mongo-driver/v2/event"
2828
"go.mongodb.org/mongo-driver/v2/internal/assert"
2929
"go.mongodb.org/mongo-driver/v2/internal/httputil"
30+
"go.mongodb.org/mongo-driver/v2/internal/options"
3031
"go.mongodb.org/mongo-driver/v2/internal/ptrutil"
3132
"go.mongodb.org/mongo-driver/v2/mongo/readconcern"
3233
"go.mongodb.org/mongo-driver/v2/mongo/readpref"
@@ -156,6 +157,7 @@ func TestClientOptions(t *testing.T) {
156157
cmp.Comparer(func(r1, r2 *bson.Registry) bool { return r1 == r2 }),
157158
cmp.Comparer(func(cfg1, cfg2 *tls.Config) bool { return cfg1 == cfg2 }),
158159
cmp.Comparer(func(fp1, fp2 *event.PoolMonitor) bool { return fp1 == fp2 }),
160+
cmp.Comparer(options.Equal),
159161
cmp.AllowUnexported(ClientOptions{}),
160162
cmpopts.IgnoreFields(http.Client{}, "Transport"),
161163
); diff != "" {

0 commit comments

Comments
 (0)