Initial commit
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
commit
ef9aca1f3b
26 changed files with 1668 additions and 0 deletions
40
src/internal/utils_test.go
Normal file
40
src/internal/utils_test.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHumanDuration(t *testing.T) {
|
||||
tests := []struct {
|
||||
i int
|
||||
expected string
|
||||
}{
|
||||
{-1, ""},
|
||||
{1, "1 second"},
|
||||
{3, "3 seconds"},
|
||||
{60, "1 minute"},
|
||||
{120, "2 minutes"},
|
||||
{3600, "1 hour"},
|
||||
{7200, "2 hours"},
|
||||
{86400, "1 day"},
|
||||
{172800, "2 days"},
|
||||
{604800, "1 week"},
|
||||
{1209600, "2 weeks"},
|
||||
{2678400, "1 month"},
|
||||
{5356800, "2 months"},
|
||||
{31536000, "1 year"},
|
||||
{63072000, "2 years"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(fmt.Sprintf("TestHumanDuration#%d", tc.i), func(t *testing.T) {
|
||||
got := HumanDuration(tc.i)
|
||||
if got != tc.expected {
|
||||
t.Errorf("got '%s', want '%s'", got, tc.expected)
|
||||
} else {
|
||||
t.Logf("got '%s', want '%s'", got, tc.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue