跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

server_windows_test.go

84 行 · 1.9 KB历史下载
1package sftp
2
3import (
4 "testing"
5)
6
7func TestServer_toLocalPath(t *testing.T) {
8 tests := []struct {
9 name string
10 withWorkDir string
11 p string
12 want string
13 }{
14 {
15 name: "empty path with no workdir",
16 p: "",
17 want: "",
18 },
19 {
20 name: "relative path with no workdir",
21 p: "file",
22 want: "file",
23 },
24 {
25 name: "absolute path with no workdir",
26 p: "/file",
27 want: "\\file",
28 },
29 {
30 name: "workdir and empty path",
31 withWorkDir: "C:\\Users\\User",
32 p: "",
33 want: "C:\\Users\\User",
34 },
35 {
36 name: "workdir and relative path",
37 withWorkDir: "C:\\Users\\User",
38 p: "file",
39 want: "C:\\Users\\User\\file",
40 },
41 {
42 name: "workdir and relative path with .",
43 withWorkDir: "C:\\Users\\User",
44 p: ".",
45 want: "C:\\Users\\User",
46 },
47 {
48 name: "workdir and relative path with . and file",
49 withWorkDir: "C:\\Users\\User",
50 p: "./file",
51 want: "C:\\Users\\User\\file",
52 },
53 {
54 name: "workdir and absolute path",
55 withWorkDir: "C:\\Users\\User",
56 p: "/C:/file",
57 want: "C:\\file",
58 },
59 {
60 name: "workdir and non-unixy path prefixes workdir",
61 withWorkDir: "C:\\Users\\User",
62 p: "C:\\file",
63 // This may look like a bug but it is the result of passing
64 // invalid input (a non-unixy path) to the server.
65 want: "C:\\Users\\User\\C:\\file",
66 },
67 }
68 for _, tt := range tests {
69 t.Run(tt.name, func(t *testing.T) {
70 // We don't need to initialize the Server further to test
71 // toLocalPath behavior.
72 s := &Server{}
73 if tt.withWorkDir != "" {
74 if err := WithServerWorkingDirectory(tt.withWorkDir)(s); err != nil {
75 t.Fatal(err)
76 }
77 }
78
79 if got := s.toLocalPath(tt.p); got != tt.want {
80 t.Errorf("Server.toLocalPath() = %q, want %q", got, tt.want)
81 }
82 })
83 }
84}