同步完整源码至远程:扁平化重构现状 + 未入库源文件
- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、 packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件 - 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源) - 构建产物(bin/target/dist)与签名私钥仍按规则排除
This commit is contained in:
1 parent
5c0be49217
commit
2c0bfafd8d
269 files changed
+10372
-16435
No files matched your search
@@ -1,8 +1,10 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestParseRedisAddrs(t *testing.T) {
|
||||
@@ -26,3 +28,32 @@ func TestOpenRedisModeValidation(t *testing.T) {
|
||||
t.Fatalf("cluster without nodes: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeRedisModeInfersClusterFromNodes(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
c ConnReq
|
||||
want string
|
||||
}{
|
||||
{"空配置回单机", ConnReq{}, "standalone"},
|
||||
{"显式 sentinel 保留", ConnReq{RedisMode: "Sentinel", RedisNodes: "127.0.0.1:26379"}, "sentinel"},
|
||||
{"多节点未选模式推断 cluster", ConnReq{RedisNodes: "127.0.0.1:7101,127.0.0.1:7102"}, "cluster"},
|
||||
{"单节点未选模式保持单机", ConnReq{Host: "127.0.0.1", Port: 6379, RedisNodes: "127.0.0.1:6379"}, "standalone"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := normalizeRedisMode(tc.c); got != tc.want {
|
||||
t.Fatalf("%s: want %s, got %s", tc.name, tc.want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRedisErrMovedHint(t *testing.T) {
|
||||
res := redisErr(time.Now(), errors.New("MOVED 12503 127.0.0.1:7103"))
|
||||
if !strings.Contains(res.Error, "部署模式切为 Cluster") {
|
||||
t.Fatalf("MOVED 错误应带模式切换提示: %q", res.Error)
|
||||
}
|
||||
res = redisErr(time.Now(), errors.New("WRONGTYPE Operation against"))
|
||||
if strings.Contains(res.Error, "Cluster") {
|
||||
t.Fatalf("普通错误不应带集群提示: %q", res.Error)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user