Initial commit

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-08-21 16:22:03 +02:00
commit ef9aca1f3b
Signed by: jriou
GPG key ID: 9A099EDA51316854
26 changed files with 1668 additions and 0 deletions

View 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)
}
})
}
}