@@ -202,7 +202,6 @@ func (t *T) cleanup() {
202
202
203
203
// always disconnect the client regardless of clientType because Client.Disconnect will work against
204
204
// all deployments
205
- // _ = t.fpClient.Disconnect(context.Background())
206
205
_ = t .Client .Disconnect (context .Background ())
207
206
}
208
207
@@ -228,7 +227,7 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
228
227
229
228
// for shareClient, inherit the client from the parent
230
229
if sub .shareClient != nil && * sub .shareClient && sub .clientType == t .clientType {
231
- // sub.fpClient = t.fpClient
230
+ sub .fpClient = t .fpClient
232
231
sub .Client = t .Client
233
232
}
234
233
// only create a client if not already set
@@ -259,7 +258,6 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
259
258
}
260
259
// only disconnect client if it's not being shared
261
260
if sub .shareClient == nil || ! * sub .shareClient {
262
- // _ = sub.fpClient.Disconnect(context.Background())
263
261
_ = sub .Client .Disconnect (context .Background ())
264
262
}
265
263
assert .Equal (sub , 0 , sessions , "%v sessions checked out" , sessions )
@@ -409,7 +407,6 @@ func (t *T) ResetClient(opts *options.ClientOptions) {
409
407
t .clientOpts = opts
410
408
}
411
409
412
- // _ = t.fpClient.Disconnect(context.Background())
413
410
_ = t .Client .Disconnect (context .Background ())
414
411
t .createTestClient ()
415
412
t .DB = t .Client .Database (t .dbName )
@@ -631,10 +628,13 @@ func sanitizeCollectionName(db string, coll string) string {
631
628
}
632
629
633
630
func (t * T ) createTestClient () {
634
- clientOpts := t . clientOpts
635
- if clientOpts == nil {
631
+ var clientOpts * options. ClientOptions
632
+ if t . clientOpts == nil {
636
633
// default opts
637
634
clientOpts = options .Client ().SetWriteConcern (MajorityWc ).SetReadPreference (PrimaryRp )
635
+ } else {
636
+ opts := * t .clientOpts
637
+ clientOpts = & opts
638
638
}
639
639
// set ServerAPIOptions to latest version if required
640
640
if clientOpts .Deployment == nil && t .clientType != Mock && clientOpts .ServerAPIOptions == nil && testContext .requireAPIVersion {
@@ -726,9 +726,8 @@ func (t *T) createTestClient() {
726
726
t .Fatalf ("error connecting client: %v" , err )
727
727
}
728
728
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 )
732
731
if err != nil {
733
732
t .Fatalf ("error creating client: %v" , err )
734
733
}
0 commit comments