Skip to content

Commit d924de1

Browse files
committed
fix test
1 parent 0e1b9a3 commit d924de1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/util/sec_to_time.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func SecToHours(durationVal any) string {
2222
formattedTime = formatTime(minutes, "minute", formattedTime)
2323

2424
// The formatTime() function always appends a space at the end. This will be trimmed
25-
if formattedTime == "" {
25+
if formattedTime == "" && seconds > 0 {
2626
formattedTime = formatTime(seconds, "second", "")
2727
}
2828
return strings.TrimRight(formattedTime, " ")

modules/util/sec_to_time_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ func TestSecToHours(t *testing.T) {
2424
assert.Equal(t, "672 hours", SecToHours(4*7*day))
2525
assert.Equal(t, "1 second", SecToHours(1))
2626
assert.Equal(t, "2 seconds", SecToHours(2))
27+
assert.Equal(t, "", SecToHours(nil)) // old behavior, empty means no output
2728
}

0 commit comments

Comments
 (0)