mirror of
https://github.com/go-gitea/gitea
synced 2025-01-21 23:24:29 +00:00
eef635523a
Try to backport #33315, the only trivial conflict is in the helper functions map in the helper.go Fix #33333 Co-authored-by: Sysoev, Vladimir <i@vsysoev.ru>
26 lines
737 B
Go
26 lines
737 B
Go
// Copyright 2022 Gitea. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package util
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSecToHours(t *testing.T) {
|
|
second := int64(1)
|
|
minute := 60 * second
|
|
hour := 60 * minute
|
|
day := 24 * hour
|
|
|
|
assert.Equal(t, "1 minute", SecToHours(minute+6*second))
|
|
assert.Equal(t, "1 hour", SecToHours(hour))
|
|
assert.Equal(t, "1 hour", SecToHours(hour+second))
|
|
assert.Equal(t, "14 hours 33 minutes", SecToHours(14*hour+33*minute+30*second))
|
|
assert.Equal(t, "156 hours 30 minutes", SecToHours(6*day+12*hour+30*minute+18*second))
|
|
assert.Equal(t, "98 hours 16 minutes", SecToHours(4*day+2*hour+16*minute+58*second))
|
|
assert.Equal(t, "672 hours", SecToHours(4*7*day))
|
|
}
|