MCPcopy Create free account
hub / github.com/diillson/chatcli / TestExpandPath

Function TestExpandPath

utils/utils_test.go:106–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func TestExpandPath(t *testing.T) {
107 homeDir, err := os.UserHomeDir()
108 assert.NoError(t, err)
109
110 testCases := []struct {
111 name string
112 input string
113 expected string
114 hasError bool
115 }{
116 {"Just tilde", "~", homeDir, false},
117 {"Tilde with path", "~/documents", filepath.Join(homeDir, "documents"), false},
118 {"Absolute path", "/etc/hosts", "/etc/hosts", false},
119 {"Relative path", "./test", "./test", false},
120 {"Unsupported tilde user", "~user/docs", "", true},
121 }
122
123 for _, tc := range testCases {
124 t.Run(tc.name, func(t *testing.T) {
125 expanded, err := ExpandPath(tc.input)
126 if tc.hasError {
127 assert.Error(t, err)
128 } else {
129 assert.NoError(t, err)
130 assert.Equal(t, tc.expected, expanded)
131 }
132 })
133 }
134}

Callers

nothing calls this directly

Calls 4

ExpandPathFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected