MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / TestExpand

Function TestExpand

internal/pathutil/pathutil_test.go:11–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestExpand(t *testing.T) {
12 t.Setenv("HOME", "/home/test")
13
14 tests := []struct {
15 name string
16 in string
17 want string
18 }{
19 {name: "empty", in: "", want: ""},
20 {name: "absolute", in: "/etc/passwd", want: "/etc/passwd"},
21 {name: "relative", in: "foo/bar", want: "foo/bar"},
22 {name: "tilde alone", in: "~", want: "/home/test"},
23 {name: "tilde slash", in: "~/", want: "/home/test"},
24 {name: "tilde subdir", in: "~/cfg/file", want: "/home/test/cfg/file"},
25 {name: "literal tilde mid-path", in: "/var/~/foo", want: "/var/~/foo"},
26 }
27
28 for _, tc := range tests {
29 tc := tc
30 t.Run(tc.name, func(t *testing.T) {
31 t.Parallel()
32 got := pathutil.Expand(tc.in)
33 if got != tc.want {
34 t.Fatalf("Expand(%q) = %q, want %q", tc.in, got, tc.want)
35 }
36 })
37 }
38}
39
40func TestConfigDirHonorsEnvironment(t *testing.T) {
41 t.Setenv("HOME", "/home/test")

Callers

nothing calls this directly

Calls 2

ExpandFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected