@@ -16,6 +16,7 @@ import (
16
16
17
17
"github.com/stretchr/testify/require"
18
18
"go.mongodb.org/mongo-driver/bson"
19
+ "go.mongodb.org/mongo-driver/bson/bsoncodec"
19
20
"go.mongodb.org/mongo-driver/bson/primitive"
20
21
"go.mongodb.org/mongo-driver/internal/testutil"
21
22
"go.mongodb.org/mongo-driver/mongo/options"
@@ -58,6 +59,8 @@ func compareDbs(t *testing.T, expected *Database, got *Database) {
58
59
t .Errorf ("expected read concern %#v. got %#v" , expected .readConcern , got .readConcern )
59
60
case expected .writeConcern != got .writeConcern :
60
61
t .Errorf ("expected write concern %#v. got %#v" , expected .writeConcern , got .writeConcern )
62
+ case expected .registry != got .registry :
63
+ t .Errorf ("expected registry %#v, got %#v" , expected .registry , got .registry )
61
64
}
62
65
}
63
66
@@ -69,14 +72,16 @@ func TestDatabase_Options(t *testing.T) {
69
72
wc2 := writeconcern .New (writeconcern .W (10 ))
70
73
rcLocal := readconcern .Local ()
71
74
rcMajority := readconcern .Majority ()
75
+ reg := bsoncodec .NewRegistryBuilder ().Build ()
72
76
73
77
opts := options .Database ().SetReadPreference (rpPrimary ).SetReadConcern (rcLocal ).SetWriteConcern (wc1 ).
74
- SetReadPreference (rpSecondary ).SetReadConcern (rcMajority ).SetWriteConcern (wc2 )
78
+ SetReadPreference (rpSecondary ).SetReadConcern (rcMajority ).SetWriteConcern (wc2 ). SetRegistry ( reg )
75
79
76
80
expectedDb := & Database {
77
81
readConcern : rcMajority ,
78
82
readPreference : rpSecondary ,
79
83
writeConcern : wc2 ,
84
+ registry : reg ,
80
85
}
81
86
82
87
t .Run ("IndividualOptions" , func (t * testing.T ) {
@@ -94,9 +99,10 @@ func TestDatabase_InheritOptions(t *testing.T) {
94
99
rcLocal := readconcern .Local ()
95
100
client .readPreference = rpPrimary
96
101
client .readConcern = rcLocal
102
+ reg := bsoncodec .NewRegistryBuilder ().Build ()
97
103
98
104
wc1 := writeconcern .New (writeconcern .W (10 ))
99
- db := client .Database (name , options .Database ().SetWriteConcern (wc1 ))
105
+ db := client .Database (name , options .Database ().SetWriteConcern (wc1 ). SetRegistry ( reg ) )
100
106
101
107
// db should inherit read preference and read concern from client
102
108
switch {
@@ -106,6 +112,8 @@ func TestDatabase_InheritOptions(t *testing.T) {
106
112
t .Errorf ("expected read concern local. got %#v" , db .readConcern )
107
113
case db .writeConcern != wc1 :
108
114
t .Errorf ("expected write concern %#v. got %#v" , wc1 , db .writeConcern )
115
+ case db .registry != reg :
116
+ t .Errorf ("expected registry %#v, got %#v" , reg , db .registry )
109
117
}
110
118
}
111
119
0 commit comments