MCPcopy Create free account
hub / github.com/gogs/gogs / TestIsRepositoryGitPath

Function TestIsRepositoryGitPath

internal/database/repo_editor_test.go:9–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsRepositoryGitPath(t *testing.T) {
10 tests := []struct {
11 path string
12 wantVal bool
13 }{
14 {path: ".git", wantVal: true},
15 {path: "./.git", wantVal: true},
16 {path: ".git/hooks/pre-commit", wantVal: true},
17 {path: ".git/hooks", wantVal: true},
18 {path: "dir/.git", wantVal: true},
19
20 // Case-insensitive file system
21 {path: ".Git", wantVal: true},
22 {path: "./.Git", wantVal: true},
23 {path: ".Git/hooks/pre-commit", wantVal: true},
24 {path: ".Git/hooks", wantVal: true},
25 {path: "dir/.Git", wantVal: true},
26
27 {path: ".gitignore", wantVal: false},
28 {path: "dir/.gitkeep", wantVal: false},
29
30 // Windows-specific
31 {path: `.git\`, wantVal: true},
32 {path: `.git\hooks\pre-commit`, wantVal: true},
33 {path: `.git\hooks`, wantVal: true},
34 {path: `dir\.git`, wantVal: true},
35
36 {path: `.\.git.`, wantVal: true},
37 {path: `.\.git.\`, wantVal: true},
38 {path: `.git.\hooks\pre-commit`, wantVal: true},
39 {path: `.git.\hooks`, wantVal: true},
40 {path: `dir\.git.`, wantVal: true},
41
42 {path: "./.git.", wantVal: true},
43 {path: "./.git./", wantVal: true},
44 {path: ".git./hooks/pre-commit", wantVal: true},
45 {path: ".git./hooks", wantVal: true},
46 {path: "dir/.git.", wantVal: true},
47
48 {path: `dir\.gitkeep`, wantVal: false},
49 }
50 for _, test := range tests {
51 t.Run(test.path, func(t *testing.T) {
52 assert.Equal(t, test.wantVal, isRepositoryGitPath(test.path))
53 })
54 }
55}

Callers

nothing calls this directly

Calls 1

isRepositoryGitPathFunction · 0.85

Tested by

no test coverage detected