mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-10 11:20:24 +08:00
重构数据库备份与恢复模块 (#80)
* fix: 保存 LastResult 时截断字符串过长部分,以避免数据库报错 * refactor: 新增 entity.DbTaskBase 和 persistence.dbTaskBase, 用于实现数据库备份和恢复任务处理相关部分 * fix: aeskey变更后,解密密码出现数组越界访问错误 * fix: 时间属性为零值时,保存到 mysql 数据库报错 * refactor db.infrastructure.service.scheduler * feat: 实现立即备份功能 * refactor db.infrastructure.service.db_instance * refactor: 从数据库中获取数据库备份目录、mysql文件路径等配置信息 * fix: 数据库备份和恢复问题 * fix: 修改 .gitignore 文件,忽略数据库备份目录和数据库程序目录
This commit is contained in:
32
server/pkg/utils/stringx/stringx_test.go
Normal file
32
server/pkg/utils/stringx/stringx_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package stringx
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTruncateStr(t *testing.T) {
|
||||
testCases := []struct {
|
||||
data string
|
||||
length int
|
||||
want string
|
||||
}{
|
||||
{"123一二三", 0, ""},
|
||||
{"123一二三", 1, "1"},
|
||||
{"123一二三", 3, "123"},
|
||||
{"123一二三", 4, "123"},
|
||||
{"123一二三", 5, "123"},
|
||||
{"123一二三", 6, "123一"},
|
||||
{"123一二三", 7, "123一"},
|
||||
{"123一二三", 11, "123一二"},
|
||||
{"123一二三", 12, "123一二三"},
|
||||
{"123一二三", 13, "123一二三"},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(strconv.Itoa(tc.length), func(t *testing.T) {
|
||||
got := TruncateStr(tc.data, tc.length)
|
||||
require.Equal(t, tc.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user