MCPcopy Index your code
hub / github.com/go-git/go-git / TestValidPath

Function TestValidPath

worktree_test.go:3199–3247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3197}
3198
3199func TestValidPath(t *testing.T) {
3200 type testcase struct {
3201 path string
3202 wantErr bool
3203 }
3204
3205 tests := []testcase{
3206 {".git", true},
3207 {".git/b", true},
3208 {".git\\b", true},
3209 {"git~1", true},
3210 {"a/../b", true},
3211 {"a\\..\\b", true},
3212 {"/", true},
3213 {"", true},
3214 {".gitmodules", false},
3215 {".gitignore", false},
3216 {"a..b", false},
3217 {".", true},
3218 {"a/.git/b", true},
3219 {"a\\.git\\b", true},
3220 {"a/.git", false},
3221 {"a\\.git", false},
3222 }
3223
3224 if runtime.GOOS == "windows" {
3225 tests = append(tests, []testcase{
3226 {"\\\\a\\b", true},
3227 {"C:\\a\\b", true},
3228 {".git . . .", true},
3229 {".git . . ", true},
3230 {".git ", true},
3231 {".git.", true},
3232 {".git::$INDEX_ALLOCATION", true},
3233 }...)
3234 }
3235
3236 fs := newWorktreeFilesystem(nil, defaultProtectNTFS(), defaultProtectHFS())
3237 for _, tc := range tests {
3238 t.Run(tc.path, func(t *testing.T) {
3239 err := fs.validPath(tc.path)
3240 if tc.wantErr {
3241 assert.Error(t, err)
3242 } else {
3243 assert.NoError(t, err)
3244 }
3245 })
3246 }
3247}
3248
3249// TestWorktreeFilesystemMkdirAllRootIsNoop locks in the contract that
3250// MkdirAll on a root-equivalent path is a silent no-op against the

Callers

nothing calls this directly

Calls 5

newWorktreeFilesystemFunction · 0.85
defaultProtectNTFSFunction · 0.85
defaultProtectHFSFunction · 0.85
validPathMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…