MCPcopy Create free account
hub / github.com/github/gh-aw / TestSanitizePath

Function TestSanitizePath

pkg/parser/import_cache_test.go:126–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestSanitizePath(t *testing.T) {
127 tests := []struct {
128 name string
129 input string
130 expected string
131 }{
132 {
133 name: "simple path",
134 input: "workflows/test.md",
135 expected: "workflows_test.md",
136 },
137 {
138 name: "nested path",
139 input: "a/b/c/file.md",
140 expected: "a_b_c_file.md",
141 },
142 {
143 name: "already flat",
144 input: "file.md",
145 expected: "file.md",
146 },
147 {
148 name: "path with dots cleaned",
149 input: "a/./b/file.md",
150 expected: "a_b_file.md",
151 },
152 {
153 name: "empty string",
154 input: "",
155 expected: ".",
156 },
157 {
158 name: "trailing slash",
159 input: "a/b/",
160 expected: "a_b",
161 },
162 {
163 name: "single dot component",
164 input: "a/./b",
165 expected: "a_b",
166 },
167 {
168 name: "leading slash becomes root-like",
169 input: "/absolute/path",
170 expected: "_absolute_path",
171 },
172 {
173 name: "dot-prefixed path cleaned",
174 input: "./file.md",
175 expected: "file.md",
176 },
177 {
178 name: "multiple consecutive slashes cleaned",
179 input: "a//b/file.md",
180 expected: "a_b_file.md",
181 },
182 }
183

Callers

nothing calls this directly

Calls 2

sanitizePathFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected