@@ -81,7 +81,7 @@ type T struct {
8181
8282 // options copied to sub-tests
8383 clientType ClientType
84- clientOpts * options.ClientOptionsBuilder
84+ clientOpts * options.ClientOptions
8585 collOpts * options.CollectionOptionsBuilder
8686 shareClient * bool
8787
@@ -359,7 +359,7 @@ func (t *T) ClearEvents() {
359359// If t.Coll is not-nil, it will be reset to use the new client. Should only be called if the existing client is
360360// not nil. This will Disconnect the existing client but will not drop existing collections. To do so, ClearCollections
361361// must be called before calling ResetClient.
362- func (t * T ) ResetClient (opts * options.ClientOptionsBuilder ) {
362+ func (t * T ) ResetClient (opts * options.ClientOptions ) {
363363 if opts != nil {
364364 t .clientOpts = opts
365365 }
@@ -592,18 +592,13 @@ func (t *T) createTestClient() {
592592 clientOpts = options .Client ().SetWriteConcern (MajorityWc ).SetReadPreference (PrimaryRp )
593593 }
594594
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-
600595 // 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 {
602597 clientOpts .SetServerAPIOptions (options .ServerAPI (driver .TestServerAPIVersion ))
603598 }
604599
605600 // Setup command monitor
606- var customMonitor = args .Monitor
601+ var customMonitor = clientOpts .Monitor
607602 clientOpts .SetMonitor (& event.CommandMonitor {
608603 Started : func (ctx context.Context , cse * event.CommandStartedEvent ) {
609604 if customMonitor != nil && customMonitor .Started != nil {
@@ -631,8 +626,8 @@ func (t *T) createTestClient() {
631626 },
632627 })
633628 // 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
636631
637632 clientOpts .SetPoolMonitor (& event.PoolMonitor {
638633 Event : func (evt * event.PoolEvent ) {
@@ -650,6 +645,7 @@ func (t *T) createTestClient() {
650645 })
651646 }
652647
648+ var err error
653649 switch t .clientType {
654650 case Pinned :
655651 // pin to first mongos
@@ -658,15 +654,13 @@ func (t *T) createTestClient() {
658654 t .Client , err = mongo .Connect (uriOpts , clientOpts )
659655 case Mock :
660656 // clear pool monitor to avoid configuration error
661- args , _ = mongoutil.NewOptions [options.ClientOptions ](clientOpts )
662657
663- args .PoolMonitor = nil
658+ clientOpts .PoolMonitor = nil
664659
665660 t .mockDeployment = drivertest .NewMockDeployment ()
666- args .Deployment = t .mockDeployment
661+ clientOpts .Deployment = t .mockDeployment
667662
668- opts := mongoutil .NewOptionsLister (args , nil )
669- t .Client , err = mongo .Connect (opts )
663+ t .Client , err = mongo .Connect (clientOpts )
670664 case Proxy :
671665 t .proxyDialer = newProxyDialer ()
672666 clientOpts .SetDialer (t .proxyDialer )
@@ -676,8 +670,8 @@ func (t *T) createTestClient() {
676670 case Default :
677671 // Use a different set of options to specify the URI because clientOpts may already have a URI or host seedlist
678672 // specified.
679- var uriOpts * options.ClientOptionsBuilder
680- if args .Deployment == nil {
673+ var uriOpts * options.ClientOptions
674+ if clientOpts .Deployment == nil {
681675 // Only specify URI if the deployment is not set to avoid setting topology/server options along with the
682676 // deployment.
683677 uriOpts = options .Client ().ApplyURI (testContext .connString .Original )
0 commit comments