Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Feb 2, 2025
1 parent 0e1b9a3 commit d924de1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/util/sec_to_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func SecToHours(durationVal any) string {
formattedTime = formatTime(minutes, "minute", formattedTime)

// The formatTime() function always appends a space at the end. This will be trimmed
if formattedTime == "" {
if formattedTime == "" && seconds > 0 {
formattedTime = formatTime(seconds, "second", "")
}
return strings.TrimRight(formattedTime, " ")
Expand Down
1 change: 1 addition & 0 deletions modules/util/sec_to_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ func TestSecToHours(t *testing.T) {
assert.Equal(t, "672 hours", SecToHours(4*7*day))
assert.Equal(t, "1 second", SecToHours(1))
assert.Equal(t, "2 seconds", SecToHours(2))
assert.Equal(t, "", SecToHours(nil)) // old behavior, empty means no output
}

0 comments on commit d924de1

Please sign in to comment.