@@ -81,7 +81,7 @@ type T struct {
81
81
82
82
// options copied to sub-tests
83
83
clientType ClientType
84
- clientOpts * options.ClientOptionsBuilder
84
+ clientOpts * options.ClientOptions
85
85
collOpts * options.CollectionOptionsBuilder
86
86
shareClient * bool
87
87
@@ -359,7 +359,7 @@ func (t *T) ClearEvents() {
359
359
// If t.Coll is not-nil, it will be reset to use the new client. Should only be called if the existing client is
360
360
// not nil. This will Disconnect the existing client but will not drop existing collections. To do so, ClearCollections
361
361
// must be called before calling ResetClient.
362
- func (t * T ) ResetClient (opts * options.ClientOptionsBuilder ) {
362
+ func (t * T ) ResetClient (opts * options.ClientOptions ) {
363
363
if opts != nil {
364
364
t .clientOpts = opts
365
365
}
@@ -592,18 +592,13 @@ func (t *T) createTestClient() {
592
592
clientOpts = options .Client ().SetWriteConcern (MajorityWc ).SetReadPreference (PrimaryRp )
593
593
}
594
594
595
- args , err := mongoutil.NewOptions [options.ClientOptions ](clientOpts )
596
- if err != nil {
597
- t .Fatalf ("failed to construct options from builder: %v" , err )
598
- }
599
-
600
595
// set ServerAPIOptions to latest version if required
601
- if args .Deployment == nil && t .clientType != Mock && args .ServerAPIOptions == nil && testContext .requireAPIVersion {
596
+ if clientOpts .Deployment == nil && t .clientType != Mock && clientOpts .ServerAPIOptions == nil && testContext .requireAPIVersion {
602
597
clientOpts .SetServerAPIOptions (options .ServerAPI (driver .TestServerAPIVersion ))
603
598
}
604
599
605
600
// Setup command monitor
606
- var customMonitor = args .Monitor
601
+ var customMonitor = clientOpts .Monitor
607
602
clientOpts .SetMonitor (& event.CommandMonitor {
608
603
Started : func (ctx context.Context , cse * event.CommandStartedEvent ) {
609
604
if customMonitor != nil && customMonitor .Started != nil {
@@ -631,8 +626,8 @@ func (t *T) createTestClient() {
631
626
},
632
627
})
633
628
// only specify connection pool monitor if no deployment is given
634
- if args .Deployment == nil {
635
- previousPoolMonitor := args .PoolMonitor
629
+ if clientOpts .Deployment == nil {
630
+ previousPoolMonitor := clientOpts .PoolMonitor
636
631
637
632
clientOpts .SetPoolMonitor (& event.PoolMonitor {
638
633
Event : func (evt * event.PoolEvent ) {
@@ -650,6 +645,7 @@ func (t *T) createTestClient() {
650
645
})
651
646
}
652
647
648
+ var err error
653
649
switch t .clientType {
654
650
case Pinned :
655
651
// pin to first mongos
@@ -658,15 +654,13 @@ func (t *T) createTestClient() {
658
654
t .Client , err = mongo .Connect (uriOpts , clientOpts )
659
655
case Mock :
660
656
// clear pool monitor to avoid configuration error
661
- args , _ = mongoutil.NewOptions [options.ClientOptions ](clientOpts )
662
657
663
- args .PoolMonitor = nil
658
+ clientOpts .PoolMonitor = nil
664
659
665
660
t .mockDeployment = drivertest .NewMockDeployment ()
666
- args .Deployment = t .mockDeployment
661
+ clientOpts .Deployment = t .mockDeployment
667
662
668
- opts := mongoutil .NewOptionsLister (args , nil )
669
- t .Client , err = mongo .Connect (opts )
663
+ t .Client , err = mongo .Connect (clientOpts )
670
664
case Proxy :
671
665
t .proxyDialer = newProxyDialer ()
672
666
clientOpts .SetDialer (t .proxyDialer )
@@ -676,8 +670,8 @@ func (t *T) createTestClient() {
676
670
case Default :
677
671
// Use a different set of options to specify the URI because clientOpts may already have a URI or host seedlist
678
672
// specified.
679
- var uriOpts * options.ClientOptionsBuilder
680
- if args .Deployment == nil {
673
+ var uriOpts * options.ClientOptions
674
+ if clientOpts .Deployment == nil {
681
675
// Only specify URI if the deployment is not set to avoid setting topology/server options along with the
682
676
// deployment.
683
677
uriOpts = options .Client ().ApplyURI (testContext .connString .Original )
0 commit comments