Files
MyGolandRelease/internal/app/renameentry_test.go
T
zerorigin a80c0f886a MyGoland 首次提交:Go 轻量 IDE
- 编辑器:多标签、语法高亮、gopls 全套(补全/诊断/跳转/重命名/代码动作/内联提示/签名大纲)
- 调试:Delve DAP(断点/条件断点/变量树/表达式求值/goroutine 列表)
- 测试:结果树、覆盖率行着色、失败跳源码、-run 精确运行、行号可跑标记
- Git:状态着色、选择性暂存提交、pull/push、历史并排对比
- 本地历史 + 自动快照 + 崩溃恢复、会话/光标恢复
- 全局搜索替换(预览+确认,GBK 安全)、多终端、gopls 崩溃自愈
- 设计文档与验证记录见 docs/plans/
2026-11-04 16:37:05 +08:00

45 lines
1.1 KiB
Go

package app
import (
"path/filepath"
"testing"
)
func TestRemapPath(t *testing.T) {
old := filepath.Join("C:", "work", "a.go")
target := filepath.Join("C:", "work", "b.go")
cases := []struct {
in string
want string
ok bool
}{
{old, target, true},
{old + ".bak", old + ".bak", false}, // 同名前缀的邻居不能动
{filepath.Join("C:", "work", "other.go"), filepath.Join("C:", "work", "other.go"), false},
}
for _, c := range cases {
got, ok := remapPath(c.in, old, target)
if got != c.want || ok != c.ok {
t.Fatalf("remapPath(%q)=(%q,%v),期望 (%q,%v)", c.in, got, ok, c.want, c.ok)
}
}
}
func TestRemapPathDir(t *testing.T) {
old := filepath.Join("C:", "work", "pkg")
target := filepath.Join("C:", "work", "lib")
inside := filepath.Join(old, "sub", "x.go")
got, ok := remapPath(inside, old, target)
if !ok || got != filepath.Join(target, "sub", "x.go") {
t.Fatalf("目录内文件应跟着搬: (%q,%v)", got, ok)
}
sibling := filepath.Join("C:", "work", "pkg2", "y.go")
got, ok = remapPath(sibling, old, target)
if ok || got != sibling {
t.Fatalf("同前缀的兄弟目录不能动: (%q,%v)", got, ok)
}
}