File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,14 @@ Verbose: true
239
239
}
240
240
}
241
241
242
+ func getPtrTimeDuration (dur time.Duration ) * time.Duration {
243
+ return & dur
244
+ }
245
+
242
246
func TestEngine_checkedTimeout (t * testing.T ) {
243
247
tests := []struct {
244
248
name string
245
- timeout time.Duration
249
+ timeout * time.Duration
246
250
expect time.Duration
247
251
}{
248
252
{
@@ -251,26 +255,31 @@ func TestEngine_checkedTimeout(t *testing.T) {
251
255
},
252
256
{
253
257
name : "less" ,
254
- timeout : time .Millisecond * 500 ,
258
+ timeout : getPtrTimeDuration ( time .Millisecond * 500 ) ,
255
259
expect : time .Millisecond * 500 ,
256
260
},
257
261
{
258
262
name : "equal" ,
259
- timeout : time .Second ,
263
+ timeout : getPtrTimeDuration ( time .Second ) ,
260
264
expect : time .Second ,
261
265
},
262
266
{
263
267
name : "more" ,
264
- timeout : time .Millisecond * 1500 ,
268
+ timeout : getPtrTimeDuration ( time .Millisecond * 1500 ) ,
265
269
expect : time .Millisecond * 1500 ,
266
270
},
271
+ {
272
+ name : "set zero" ,
273
+ timeout : getPtrTimeDuration (0 ),
274
+ expect : 0 ,
275
+ },
267
276
}
268
277
269
278
ng := newEngine (RestConf {
270
279
Timeout : 1000 ,
271
280
})
272
281
for _ , test := range tests {
273
- assert .Equal (t , test .expect , ng .checkedTimeout (& test .timeout ))
282
+ assert .Equal (t , test .expect , ng .checkedTimeout (test .timeout ))
274
283
}
275
284
}
276
285
Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ func TestWithPriority(t *testing.T) {
345
345
func TestWithTimeout (t * testing.T ) {
346
346
var fr featuredRoutes
347
347
WithTimeout (time .Hour )(& fr )
348
- assert .Equal (t , time .Hour , fr .timeout )
348
+ assert .Equal (t , time .Hour , * fr .timeout )
349
349
}
350
350
351
351
func TestWithTLSConfig (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments