@@ -202,7 +202,6 @@ func (t *T) cleanup() {
202202
203203 // always disconnect the client regardless of clientType because Client.Disconnect will work against
204204 // all deployments
205- // _ = t.fpClient.Disconnect(context.Background())
206205 _ = t .Client .Disconnect (context .Background ())
207206}
208207
@@ -228,7 +227,7 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
228227
229228 // for shareClient, inherit the client from the parent
230229 if sub .shareClient != nil && * sub .shareClient && sub .clientType == t .clientType {
231- // sub.fpClient = t.fpClient
230+ sub .fpClient = t .fpClient
232231 sub .Client = t .Client
233232 }
234233 // only create a client if not already set
@@ -259,7 +258,6 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
259258 }
260259 // only disconnect client if it's not being shared
261260 if sub .shareClient == nil || ! * sub .shareClient {
262- // _ = sub.fpClient.Disconnect(context.Background())
263261 _ = sub .Client .Disconnect (context .Background ())
264262 }
265263 assert .Equal (sub , 0 , sessions , "%v sessions checked out" , sessions )
@@ -409,7 +407,6 @@ func (t *T) ResetClient(opts *options.ClientOptions) {
409407 t .clientOpts = opts
410408 }
411409
412- // _ = t.fpClient.Disconnect(context.Background())
413410 _ = t .Client .Disconnect (context .Background ())
414411 t .createTestClient ()
415412 t .DB = t .Client .Database (t .dbName )
@@ -631,10 +628,13 @@ func sanitizeCollectionName(db string, coll string) string {
631628}
632629
633630func (t * T ) createTestClient () {
634- clientOpts := t . clientOpts
635- if clientOpts == nil {
631+ var clientOpts * options. ClientOptions
632+ if t . clientOpts == nil {
636633 // default opts
637634 clientOpts = options .Client ().SetWriteConcern (MajorityWc ).SetReadPreference (PrimaryRp )
635+ } else {
636+ opts := * t .clientOpts
637+ clientOpts = & opts
638638 }
639639 // set ServerAPIOptions to latest version if required
640640 if clientOpts .Deployment == nil && t .clientType != Mock && clientOpts .ServerAPIOptions == nil && testContext .requireAPIVersion {
@@ -726,9 +726,8 @@ func (t *T) createTestClient() {
726726 t .Fatalf ("error connecting client: %v" , err )
727727 }
728728
729- fpOpts := options .MergeClientOptions (uriOpts , clientOpts )
730- fpOpts .AutoEncryptionOptions = nil
731- t .fpClient , err = mongo .NewClient (fpOpts )
729+ clientOpts .AutoEncryptionOptions = nil
730+ t .fpClient , err = mongo .NewClient (uriOpts , clientOpts )
732731 if err != nil {
733732 t .Fatalf ("error creating client: %v" , err )
734733 }
0 commit comments