@@ -252,43 +252,27 @@ func TestSessions(t *testing.T) {
252
252
deleteID := extractSentSessionID (mt )
253
253
assert .Equal (mt , findID , deleteID , "expected session ID %v, got %v" , findID , deleteID )
254
254
})
255
- mt .RunOpts ("find and getMore use same ID" , noClientOpts , func (mt * mtest.T ) {
256
- testCases := []struct {
257
- name string
258
- rp * readpref.ReadPref
259
- topos []mtest.TopologyKind // if nil, all will be used
260
- }{
261
- {"primary" , readpref .Primary (), nil },
262
- {"primaryPreferred" , readpref .PrimaryPreferred (), nil },
263
- {"secondary" , readpref .Secondary (), []mtest.TopologyKind {mtest .ReplicaSet }},
264
- {"secondaryPreferred" , readpref .SecondaryPreferred (), nil },
265
- {"nearest" , readpref .Nearest (), nil },
255
+ mt .Run ("find and getMore use same ID" , func (mt * mtest.T ) {
256
+ var docs []interface {}
257
+ for i := 0 ; i < 3 ; i ++ {
258
+ docs = append (docs , bson.D {{"x" , i }})
266
259
}
267
- for _ , tc := range testCases {
268
- clientOpts := options .Client ().SetReadPreference (tc .rp ).SetWriteConcern (mtest .MajorityWc )
269
- mt .RunOpts (tc .name , mtest .NewOptions ().ClientOptions (clientOpts ).Topologies (tc .topos ... ), func (mt * mtest.T ) {
270
- var docs []interface {}
271
- for i := 0 ; i < 3 ; i ++ {
272
- docs = append (docs , bson.D {{"x" , i }})
273
- }
274
- _ , err := mt .Coll .InsertMany (mtest .Background , docs )
275
- assert .Nil (mt , err , "InsertMany error: %v" , err )
276
-
277
- // run a find that will hold onto an implicit session and record the session ID
278
- mt .ClearEvents ()
279
- cursor , err := mt .Coll .Find (mtest .Background , bson.D {}, options .Find ().SetBatchSize (2 ))
280
- assert .Nil (mt , err , "Find error: %v" , err )
281
- findID := extractSentSessionID (mt )
282
- assert .NotNil (mt , findID , "expected session ID for find, got nil" )
283
-
284
- // iterate over all documents and record the session ID of the getMore
285
- for i := 0 ; i < 3 ; i ++ {
286
- assert .True (mt , cursor .Next (mtest .Background ), "Next returned false on iteration %v" , i )
287
- }
288
- getMoreID := extractSentSessionID (mt )
289
- assert .Equal (mt , findID , getMoreID , "expected session ID %v, got %v" , findID , getMoreID )
290
- })
260
+ _ , err := mt .Coll .InsertMany (mtest .Background , docs )
261
+ assert .Nil (mt , err , "InsertMany error: %v" , err )
262
+
263
+ // run a find that will hold onto an implicit session and record the session ID
264
+ mt .ClearEvents ()
265
+ cursor , err := mt .Coll .Find (mtest .Background , bson.D {}, options .Find ().SetBatchSize (2 ))
266
+ assert .Nil (mt , err , "Find error: %v" , err )
267
+ findID := extractSentSessionID (mt )
268
+ assert .NotNil (mt , findID , "expected session ID for find, got nil" )
269
+
270
+ // iterate over all documents and record the session ID of the getMore
271
+ for i := 0 ; i < 3 ; i ++ {
272
+ assert .True (mt , cursor .Next (mtest .Background ), "Next returned false on iteration %v" , i )
291
273
}
274
+ getMoreID := extractSentSessionID (mt )
275
+ assert .Equal (mt , findID , getMoreID , "expected session ID %v, got %v" , findID , getMoreID )
292
276
})
293
277
294
278
mt .Run ("imperative API" , func (mt * mtest.T ) {
0 commit comments