diff --git a/pkg/skaffold/util/time/time.go b/pkg/skaffold/util/time/time.go index 3827bc20ea3..ccb7b816470 100644 --- a/pkg/skaffold/util/time/time.go +++ b/pkg/skaffold/util/time/time.go @@ -53,7 +53,7 @@ func Humanize(start time.Duration) string { if out.Minute() > 1 { longTime = strings.ReplaceAll(longTime, "minute", "minutes") } - if out.Second() > 1 { + if out.Second() != 1 { longTime = strings.ReplaceAll(longTime, "second", "seconds") } return longTime diff --git a/pkg/skaffold/util/time/time_test.go b/pkg/skaffold/util/time/time_test.go index fa60fdc0c84..4fdb1b8c24b 100644 --- a/pkg/skaffold/util/time/time_test.go +++ b/pkg/skaffold/util/time/time_test.go @@ -63,6 +63,10 @@ func TestHumanize(t *testing.T) { if err != nil { t.Errorf("%s", err) } + duration3, err := time.ParseDuration("1h3m0.5s") + if err != nil { + t.Errorf("%s", err) + } tests := []struct { description string value time.Duration @@ -78,6 +82,11 @@ func TestHumanize(t *testing.T) { value: duration2, expected: "5.234 seconds", }, + { + description: "Case for 1h3m0.5s (plural for fraction of second)", + value: duration3, + expected: "1 hour 3 minutes 0.5 seconds", + }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) {