@@ -13,6 +13,7 @@ import (
1313 "time"
1414
1515 "go.mongodb.org/mongo-driver/v2/internal/assert"
16+ "go.mongodb.org/mongo-driver/v2/internal/ptrutil"
1617 "go.mongodb.org/mongo-driver/v2/mongo/options"
1718)
1819
@@ -37,12 +38,6 @@ func BenchmarkNewOptions(b *testing.B) {
3738}
3839
3940func TestValidChangeStreamTimeouts (t * testing.T ) {
40- t .Parallel ()
41-
42- newDurPtr := func (dur time.Duration ) * time.Duration {
43- return & dur
44- }
45-
4641 tests := []struct {
4742 name string
4843 parent context.Context
@@ -61,7 +56,7 @@ func TestValidChangeStreamTimeouts(t *testing.T) {
6156 {
6257 name : "no context deadline and maxAwaitTimeout" ,
6358 parent : context .Background (),
64- maxAwaitTimeout : newDurPtr ( 1 ),
59+ maxAwaitTimeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
6560 timeout : nil ,
6661 wantTimeout : 0 ,
6762 want : true ,
@@ -70,50 +65,46 @@ func TestValidChangeStreamTimeouts(t *testing.T) {
7065 name : "no context deadline and timeout" ,
7166 parent : context .Background (),
7267 maxAwaitTimeout : nil ,
73- timeout : newDurPtr ( 1 ),
68+ timeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
7469 wantTimeout : 0 ,
7570 want : true ,
7671 },
7772 {
7873 name : "no context deadline and maxAwaitTime gt timeout" ,
7974 parent : context .Background (),
80- maxAwaitTimeout : newDurPtr ( 2 ),
81- timeout : newDurPtr ( 1 ),
75+ maxAwaitTimeout : ptrutil . Ptr ( time . Duration ( 2 ) ),
76+ timeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
8277 wantTimeout : 0 ,
8378 want : false ,
8479 },
8580 {
8681 name : "no context deadline and maxAwaitTime lt timeout" ,
8782 parent : context .Background (),
88- maxAwaitTimeout : newDurPtr ( 1 ),
89- timeout : newDurPtr ( 2 ),
83+ maxAwaitTimeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
84+ timeout : ptrutil . Ptr ( time . Duration ( 2 ) ),
9085 wantTimeout : 0 ,
9186 want : true ,
9287 },
9388 {
9489 name : "no context deadline and maxAwaitTime eq timeout" ,
9590 parent : context .Background (),
96- maxAwaitTimeout : newDurPtr ( 1 ),
97- timeout : newDurPtr ( 1 ),
91+ maxAwaitTimeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
92+ timeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
9893 wantTimeout : 0 ,
9994 want : false ,
10095 },
10196 {
10297 name : "no context deadline and maxAwaitTime with negative timeout" ,
10398 parent : context .Background (),
104- maxAwaitTimeout : newDurPtr ( 1 ),
105- timeout : newDurPtr ( - 1 ),
99+ maxAwaitTimeout : ptrutil . Ptr ( time . Duration ( 1 ) ),
100+ timeout : ptrutil . Ptr ( time . Duration ( - 1 ) ),
106101 wantTimeout : 0 ,
107102 want : true ,
108103 },
109104 }
110105
111106 for _ , test := range tests {
112- test := test // Capture the range variable
113-
114107 t .Run (test .name , func (t * testing.T ) {
115- t .Parallel ()
116-
117108 got := ValidMaxAwaitTimeMS (test .parent , test .timeout , test .maxAwaitTimeout )
118109 assert .Equal (t , test .want , got )
119110 })
0 commit comments