@@ -471,42 +471,34 @@ func stringPointer(s string) *string {
471471}
472472
473473func TestShowHumanizeTime (t * testing.T ) {
474- currTime := time .Now ()
475- duration1 , _ := time .ParseDuration ("1h58m30.918273645s" )
476- duration2 , _ := time .ParseDuration ("5.23494327s" )
474+ duration1 , err := time .ParseDuration ("1h58m30.918273645s" )
475+ if err != nil {
476+ t .Errorf ("%s" , err )
477+ }
478+ duration2 , err := time .ParseDuration ("5.23494327s" )
479+ if err != nil {
480+ t .Errorf ("%s" , err )
481+ }
477482 tests := []struct {
478- description string
479- value time.Time
480- expected string
481- expectedUp string
482- expectedDown string
483+ description string
484+ value time.Duration
485+ expected string
483486 }{
484487 {
485- description : "Case for 1h58m30.918273645s" ,
486- value : currTime .Add (- duration1 ),
487- expected : "1 hour 58 minutes 30.918 seconds" ,
488- expectedUp : "1 hour 58 minutes 30.919 seconds" ,
489- expectedDown : "1 hour 58 minutes 30.917 seconds" ,
488+ description : "Case for 1h58m30.918273645s" ,
489+ value : duration1 ,
490+ expected : "1 hour 58 minutes 30.918 seconds" ,
490491 },
491492 {
492- description : "Case for 5.23494327s" ,
493- value : currTime .Add (- duration2 ),
494- expected : "5.235 seconds" ,
495- expectedUp : "5.236 seconds" ,
496- expectedDown : "5.234 seconds" ,
493+ description : "Case for 5.23494327s" ,
494+ value : duration2 ,
495+ expected : "5.234 seconds" ,
497496 },
498497 }
499498 for _ , test := range tests {
500499 testutil .Run (t , test .description , func (t * testutil.T ) {
501500 humanizedValue := ShowHumanizeTime (test .value )
502- switch humanizedValue {
503- case test .expectedUp :
504- t .CheckDeepEqual (test .expectedUp , humanizedValue )
505- case test .expectedDown :
506- t .CheckDeepEqual (test .expectedDown , humanizedValue )
507- default :
508- t .CheckDeepEqual (test .expected , humanizedValue )
509- }
501+ t .CheckDeepEqual (test .expected , humanizedValue )
510502 })
511503 }
512504}
0 commit comments