1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-20 00:39:17 +08:00
1Panel/backend/app/service/database_test.go

46 lines
962 B
Go
Raw Normal View History

2022-10-21 18:50:38 +08:00
package service
import (
"fmt"
"testing"
2022-10-31 17:26:15 +08:00
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/go-redis/redis"
2022-10-21 18:50:38 +08:00
)
func TestMysql(t *testing.T) {
2022-10-31 17:26:15 +08:00
client := redis.NewClient(&redis.Options{
Addr: "172.16.10.143:6379",
Password: "",
2022-10-31 17:26:15 +08:00
DB: 0,
})
fmt.Println(client.Ping().Result())
var item dto.RedisPersistence
dir, _ := client.ConfigGet("dir").Result()
if len(dir) == 2 {
if value, ok := dir[1].(string); ok {
item.Dir = value
2022-10-31 17:26:15 +08:00
}
}
appendonly, _ := client.ConfigGet("appendonly").Result()
if len(appendonly) == 2 {
if value, ok := appendonly[1].(string); ok {
item.Appendonly = value
2022-10-31 17:26:15 +08:00
}
}
appendfsync, _ := client.ConfigGet("appendfsync").Result()
if len(appendfsync) == 2 {
if value, ok := appendfsync[1].(string); ok {
item.Appendfsync = value
2022-10-31 17:26:15 +08:00
}
}
save, _ := client.ConfigGet("save").Result()
if len(save) == 2 {
if value, ok := save[1].(string); ok {
item.Save = value
2022-10-31 17:26:15 +08:00
}
}
fmt.Println(item)
}