@@ -64,9 +64,6 @@ Verbose: true
6464` ,
6565 }
6666
67- minuteDuration := time .Minute
68- secondDuration := time .Second
69-
7067 routes := []featuredRoutes {
7168 {
7269 jwt : jwtSetting {},
@@ -76,7 +73,7 @@ Verbose: true
7673 Path : "/" ,
7774 Handler : func (w http.ResponseWriter , r * http.Request ) {},
7875 }},
79- timeout : & minuteDuration ,
76+ timeout : time . Minute ,
8077 },
8178 {
8279 priority : true ,
@@ -87,7 +84,7 @@ Verbose: true
8784 Path : "/" ,
8885 Handler : func (w http.ResponseWriter , r * http.Request ) {},
8986 }},
90- timeout : & secondDuration ,
87+ timeout : time . Second ,
9188 },
9289 {
9390 priority : true ,
@@ -230,23 +227,19 @@ Verbose: true
230227 }))
231228
232229 timeout := time .Second * 3
233- if route .timeout != nil {
234- timeout = * route .timeout
230+ if route .timeout > timeout {
231+ timeout = route .timeout
235232 }
236233 assert .Equal (t , timeout , ng .timeout )
237234 })
238235 }
239236 }
240237}
241238
242- func getPtrTimeDuration (dur time.Duration ) * time.Duration {
243- return & dur
244- }
245-
246239func TestEngine_checkedTimeout (t * testing.T ) {
247240 tests := []struct {
248241 name string
249- timeout * time.Duration
242+ timeout time.Duration
250243 expect time.Duration
251244 }{
252245 {
@@ -255,24 +248,19 @@ func TestEngine_checkedTimeout(t *testing.T) {
255248 },
256249 {
257250 name : "less" ,
258- timeout : getPtrTimeDuration ( time .Millisecond * 500 ) ,
251+ timeout : time .Millisecond * 500 ,
259252 expect : time .Millisecond * 500 ,
260253 },
261254 {
262255 name : "equal" ,
263- timeout : getPtrTimeDuration ( time .Second ) ,
256+ timeout : time .Second ,
264257 expect : time .Second ,
265258 },
266259 {
267260 name : "more" ,
268- timeout : getPtrTimeDuration ( time .Millisecond * 1500 ) ,
261+ timeout : time .Millisecond * 1500 ,
269262 expect : time .Millisecond * 1500 ,
270263 },
271- {
272- name : "set zero" ,
273- timeout : getPtrTimeDuration (0 ),
274- expect : 0 ,
275- },
276264 }
277265
278266 ng := newEngine (RestConf {
0 commit comments