@@ -16,6 +16,7 @@ import (
1616
1717 "github.com/stretchr/testify/require"
1818 "go.mongodb.org/mongo-driver/bson"
19+ "go.mongodb.org/mongo-driver/bson/bsoncodec"
1920 "go.mongodb.org/mongo-driver/bson/primitive"
2021 "go.mongodb.org/mongo-driver/internal/testutil"
2122 "go.mongodb.org/mongo-driver/mongo/options"
@@ -58,6 +59,8 @@ func compareDbs(t *testing.T, expected *Database, got *Database) {
5859 t .Errorf ("expected read concern %#v. got %#v" , expected .readConcern , got .readConcern )
5960 case expected .writeConcern != got .writeConcern :
6061 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 )
6164 }
6265}
6366
@@ -69,14 +72,16 @@ func TestDatabase_Options(t *testing.T) {
6972 wc2 := writeconcern .New (writeconcern .W (10 ))
7073 rcLocal := readconcern .Local ()
7174 rcMajority := readconcern .Majority ()
75+ reg := bsoncodec .NewRegistryBuilder ().Build ()
7276
7377 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 )
7579
7680 expectedDb := & Database {
7781 readConcern : rcMajority ,
7882 readPreference : rpSecondary ,
7983 writeConcern : wc2 ,
84+ registry : reg ,
8085 }
8186
8287 t .Run ("IndividualOptions" , func (t * testing.T ) {
@@ -94,9 +99,10 @@ func TestDatabase_InheritOptions(t *testing.T) {
9499 rcLocal := readconcern .Local ()
95100 client .readPreference = rpPrimary
96101 client .readConcern = rcLocal
102+ reg := bsoncodec .NewRegistryBuilder ().Build ()
97103
98104 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 ) )
100106
101107 // db should inherit read preference and read concern from client
102108 switch {
@@ -106,6 +112,8 @@ func TestDatabase_InheritOptions(t *testing.T) {
106112 t .Errorf ("expected read concern local. got %#v" , db .readConcern )
107113 case db .writeConcern != wc1 :
108114 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 )
109117 }
110118}
111119
0 commit comments