@@ -82,7 +82,6 @@ type T struct {
8282clientType ClientType
8383clientOpts * options.ClientOptions
8484collOpts * options.CollectionOptionsBuilder
85- shareClient * bool
8685allowFailPointsOnSharded bool
8786
8887baseOpts * Options // used to create subtests
@@ -122,9 +121,6 @@ func newT(wrapped *testing.T, opts ...*Options) *T {
122121
123122// create a set of base options for sub-tests
124123t .baseOpts = NewOptions ().ClientOptions (t .clientOpts ).CollectionOptions (t .collOpts ).ClientType (t .clientType )
125- if t .shareClient != nil {
126- t .baseOpts .ShareClient (* t .shareClient )
127- }
128124if t .allowFailPointsOnSharded {
129125t .baseOpts .AllowFailPointsOnSharded ()
130126}
@@ -143,12 +139,6 @@ func New(wrapped *testing.T, opts ...*Options) *T {
143139
144140t := newT (wrapped , opts ... )
145141
146- // only create a client if it needs to be shared in sub-tests
147- // otherwise, a new client will be created for each subtest
148- if t .shareClient != nil && * t .shareClient {
149- t .createTestClient ()
150- }
151-
152142wrapped .Cleanup (t .cleanup )
153143
154144return t
@@ -192,16 +182,10 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
192182sub .AddMockResponses (sub .mockResponses ... )
193183}
194184
195- // for shareClient, inherit the client from the parent
196- if sub .shareClient != nil && * sub .shareClient && sub .clientType == t .clientType {
197- sub .Client = t .Client
198- }
199- // only create a client if not already set
200- if sub .Client == nil {
201- if sub .createClient == nil || * sub .createClient {
202- sub .createTestClient ()
203- }
185+ if sub .createClient == nil || * sub .createClient {
186+ sub .createTestClient ()
204187}
188+
205189// create a collection for this test
206190if sub .Client != nil {
207191sub .createTestCollection ()
@@ -222,10 +206,8 @@ func (t *T) RunOpts(name string, opts *Options, callback func(mt *T)) {
222206sub .ClearFailPoints ()
223207sub .ClearCollections ()
224208}
225- // only disconnect client if it's not being shared
226- if sub .shareClient == nil || ! * sub .shareClient {
227- _ = sub .Client .Disconnect (context .Background ())
228- }
209+
210+ _ = sub .Client .Disconnect (context .Background ())
229211assert .Equal (sub , 0 , sessions , "%v sessions checked out" , sessions )
230212assert .Equal (sub , 0 , conns , "%v connections checked out" , conns )
231213}()
0 commit comments