2021-10-24 22:25:40 +08:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConvertTime(t *testing.T) {
|
|
|
|
seconds := time.Duration(50) * time.Second
|
|
|
|
fmt.Println(ConvertTime(seconds))
|
|
|
|
|
|
|
|
seconds = time.Duration(150) * time.Second
|
|
|
|
fmt.Println(ConvertTime(seconds))
|
|
|
|
|
|
|
|
seconds = time.Duration(3600) * time.Second
|
|
|
|
fmt.Println(ConvertTime(seconds))
|
|
|
|
|
|
|
|
seconds = time.Duration(1246852) * time.Second
|
|
|
|
fmt.Println(ConvertTime(seconds))
|
|
|
|
}
|
2022-05-24 19:56:06 +08:00
|
|
|
|
|
|
|
func TestUuidStr(t *testing.T) {
|
|
|
|
fmt.Println(UuidStr())
|
|
|
|
}
|
2022-06-01 21:55:03 +08:00
|
|
|
|
|
|
|
func TestMd5Str(t *testing.T) {
|
|
|
|
fmt.Println(Md5Str("123456"))
|
|
|
|
}
|
2022-06-04 13:20:33 +08:00
|
|
|
|
|
|
|
func TestParseTimeStr(t *testing.T) {
|
|
|
|
fmt.Println(ParseTimeStr(""))
|
|
|
|
}
|
2022-08-09 19:29:42 +08:00
|
|
|
|
|
|
|
func TestIsAbsPath_ReturnTrue(t *testing.T) {
|
2022-08-31 11:51:28 +08:00
|
|
|
fmt.Println(IsLocalAbsPath("D:\\my\\folder\\test"))
|
2022-08-09 19:29:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestIsAbsPath_ReturnFalse(t *testing.T) {
|
2022-08-31 11:51:28 +08:00
|
|
|
fmt.Println(IsLocalAbsPath("my\\folder\\test"))
|
2022-08-09 19:29:42 +08:00
|
|
|
}
|
2022-12-13 16:32:08 +08:00
|
|
|
|
|
|
|
func TestResizeUploadBlockSize_ReturnDefaultBlockSize(t *testing.T) {
|
|
|
|
MB := int64(1024 * 1024) // 1048576
|
|
|
|
fileSize := int64(1073741824) // 90GB
|
|
|
|
fmt.Println(ResizeUploadBlockSize(fileSize, 10*MB)) // 10485760 = 10240KB
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestResizeUploadBlockSize_ReturnNewBlockSize(t *testing.T) {
|
|
|
|
MB := int64(1024 * 1024) // 1048576
|
|
|
|
fileSize := int64(107374182400) // 100GB
|
|
|
|
fmt.Println(ResizeUploadBlockSize(fileSize, 10*MB)) // 10737664 = 10486KB
|
|
|
|
}
|