fixed issues for testing

This commit is contained in:
truecode112
2023-05-16 12:27:49 +03:00
parent 9e5f2fd4e3
commit 80f8977e59
3 changed files with 23 additions and 2 deletions
+4 -1
View File
@@ -138,7 +138,10 @@ func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string
// FileSize calculates the file size and generate user-friendly string.
func FileSize(s int64) string {
return humanize.Bytes(uint64(s))
// sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"}
// return humanize.humanateBytes(uint64(s), 1000, sizes)
// return humanize.Bytes(uint64(s))
return humanize.IBytes(uint64(s))
}
// Get FileSize bytes value from String.
+7
View File
@@ -114,6 +114,13 @@ func TestFileSize(t *testing.T) {
assert.Equal(t, "2.0 EiB", FileSize(size))
}
func TestGetFileSize(t *testing.T) {
var size int64 = 512 * 1024 * 1024 * 1024
s, err := GetFileSize("512 GiB")
assert.Equal(t, s, size)
assert.Equal(t, err, nil)
}
func TestEllipsisString(t *testing.T) {
assert.Equal(t, "...", EllipsisString("foobar", 0))
assert.Equal(t, "...", EllipsisString("foobar", 1))