@@ -64,9 +64,6 @@ Verbose: true
64
64
` ,
65
65
}
66
66
67
- minuteDuration := time .Minute
68
- secondDuration := time .Second
69
-
70
67
routes := []featuredRoutes {
71
68
{
72
69
jwt : jwtSetting {},
@@ -76,7 +73,7 @@ Verbose: true
76
73
Path : "/" ,
77
74
Handler : func (w http.ResponseWriter , r * http.Request ) {},
78
75
}},
79
- timeout : & minuteDuration ,
76
+ timeout : time . Minute ,
80
77
},
81
78
{
82
79
priority : true ,
@@ -87,7 +84,7 @@ Verbose: true
87
84
Path : "/" ,
88
85
Handler : func (w http.ResponseWriter , r * http.Request ) {},
89
86
}},
90
- timeout : & secondDuration ,
87
+ timeout : time . Second ,
91
88
},
92
89
{
93
90
priority : true ,
@@ -230,23 +227,19 @@ Verbose: true
230
227
}))
231
228
232
229
timeout := time .Second * 3
233
- if route .timeout != nil {
234
- timeout = * route .timeout
230
+ if route .timeout > timeout {
231
+ timeout = route .timeout
235
232
}
236
233
assert .Equal (t , timeout , ng .timeout )
237
234
})
238
235
}
239
236
}
240
237
}
241
238
242
- func getPtrTimeDuration (dur time.Duration ) * time.Duration {
243
- return & dur
244
- }
245
-
246
239
func TestEngine_checkedTimeout (t * testing.T ) {
247
240
tests := []struct {
248
241
name string
249
- timeout * time.Duration
242
+ timeout time.Duration
250
243
expect time.Duration
251
244
}{
252
245
{
@@ -255,24 +248,19 @@ func TestEngine_checkedTimeout(t *testing.T) {
255
248
},
256
249
{
257
250
name : "less" ,
258
- timeout : getPtrTimeDuration ( time .Millisecond * 500 ) ,
251
+ timeout : time .Millisecond * 500 ,
259
252
expect : time .Millisecond * 500 ,
260
253
},
261
254
{
262
255
name : "equal" ,
263
- timeout : getPtrTimeDuration ( time .Second ) ,
256
+ timeout : time .Second ,
264
257
expect : time .Second ,
265
258
},
266
259
{
267
260
name : "more" ,
268
- timeout : getPtrTimeDuration ( time .Millisecond * 1500 ) ,
261
+ timeout : time .Millisecond * 1500 ,
269
262
expect : time .Millisecond * 1500 ,
270
263
},
271
- {
272
- name : "set zero" ,
273
- timeout : getPtrTimeDuration (0 ),
274
- expect : 0 ,
275
- },
276
264
}
277
265
278
266
ng := newEngine (RestConf {
0 commit comments