This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsValidImageSize(t *testing.T) {
|
||||
testBase64 := "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
|
||||
maxSize := int64(10)
|
||||
result := IsValidImageSize(testBase64, maxSize)
|
||||
assert.Equal(t, result, true)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerateCipher(t *testing.T) {
|
||||
pwd := GenerateCipher("", 16)
|
||||
t.Logf("pwd: %s", pwd)
|
||||
t.Logf("pwd length: %d", len(pwd))
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEncodePassWord(t *testing.T) {
|
||||
t.Logf("EncodePassWord: %v", EncodePassWord("password"))
|
||||
}
|
||||
|
||||
func TestMultiPasswordVerify(t *testing.T) {
|
||||
pwd := "$2y$10$WFO17pdtohfeBILjEChoGeVxpDG.u9kVCKhjDAeEeNmCjIlj3tDRy"
|
||||
status := MultiPasswordVerify("bcrypt", "", "admin1", pwd)
|
||||
t.Logf("MultiPasswordVerify: %v", status)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package tool
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestFormatStringToFloat(t *testing.T) {
|
||||
var value = 1.23
|
||||
if FormatStringToFloat("1.23") != value {
|
||||
t.Errorf("Expected %f, but got %f", value, FormatStringToFloat("1.23"))
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package tool
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseRedisURI(t *testing.T) {
|
||||
uri := "redis://localhost:6379"
|
||||
addr, password, database, err := ParseRedisURI(uri)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(addr, password, database)
|
||||
}
|
||||
|
||||
func TestRedisPing(t *testing.T) {
|
||||
uri := "redis://localhost:6379"
|
||||
addr, password, database, err := ParseRedisURI(uri)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = RedisPing(addr, password, database)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFixedUniqueString(t *testing.T) {
|
||||
a := "example"
|
||||
b := "example1"
|
||||
c := "example"
|
||||
|
||||
strA1, err := FixedUniqueString(a, 8, "")
|
||||
strB1, err := FixedUniqueString(b, 8, "")
|
||||
strC1, err := FixedUniqueString(c, 8, "")
|
||||
if err != nil {
|
||||
t.Logf("Error: %v", err.Error())
|
||||
return
|
||||
}
|
||||
if strA1 != strC1 {
|
||||
t.Errorf("Expected strA1 and strC1 to be equal, got %s and %s", strA1, strC1)
|
||||
}
|
||||
if strA1 == strB1 {
|
||||
t.Errorf("Expected strA1 and strB1 to be different, got %s and %s", strA1, strB1)
|
||||
}
|
||||
t.Logf("strA1 and strB1 are not equal, strA1: %s, strB1: %s", strA1, strB1)
|
||||
t.Logf("strA1 and strC1 are equal,strA1: %s, strC1: %s", strA1, strC1)
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAddTime(t *testing.T) {
|
||||
basic := time.Now()
|
||||
expAt := AddTime("Month", 1, basic)
|
||||
|
||||
t.Logf("AddTime() success, expected year %d, got year %d, full: %v", basic.Year()+1, expAt.Year(), expAt.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
func TestGetYearDays(t *testing.T) {
|
||||
days := GetYearDays(time.Now(), 2, 1)
|
||||
t.Logf("GetYearDays() success, expected 365, got %d", days)
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/perfect-panel/server/pkg/constant"
|
||||
)
|
||||
|
||||
func TestExtractVersionNumber(t *testing.T) {
|
||||
versionNumber := ExtractVersionNumber(constant.Version)
|
||||
t.Log(versionNumber)
|
||||
}
|
||||
Reference in New Issue
Block a user