2023-03-11 14:13:35 +05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2023-04-08 14:02:36 +05:00
|
|
|
"time"
|
2023-03-11 14:13:35 +05:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSizeToApproxHuman(t *testing.T) {
|
|
|
|
assert.Equal(t, "1.0 KiB", sizeToApproxHuman(1024))
|
|
|
|
assert.Equal(t, "1.1 KiB", sizeToApproxHuman(1126))
|
|
|
|
}
|
2023-04-08 14:02:36 +05:00
|
|
|
|
|
|
|
func TestParseTime(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
input string
|
|
|
|
expected time.Time
|
|
|
|
}{
|
|
|
|
{"02.01.2006", time.Date(2006, 01, 02, 0, 0, 0, 0, time.Local)},
|
|
|
|
{"02.01.2006 15:04", time.Date(2006, 01, 02, 15, 4, 0, 0, time.Local)},
|
|
|
|
{"02.01.2006 15:04:05", time.Date(2006, 01, 02, 15, 4, 5, 0, time.Local)},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
got, err := parseTime(test.input)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, test.expected, got)
|
|
|
|
}
|
|
|
|
}
|