MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestIsPathExcluded

Function TestIsPathExcluded

internal/diff/gitignore_test.go:60–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestIsPathExcluded(t *testing.T) {
61 tests := []struct {
62 name string
63 relPath string
64 patterns []string
65 want bool
66 }{
67 {"hardcoded dir .git", ".git", nil, true},
68 {"hardcoded dir prefix", ".git/config", nil, true},
69 {"node_modules dir pattern", "node_modules/foo.js", []string{"node_modules/"}, true},
70 {"gitignore pattern match", "debug.log", []string{"*.log"}, true},
71 {"no match", "main.go", []string{"*.log"}, false},
72 {"no patterns", "main.go", nil, false},
73 }
74 for _, tt := range tests {
75 t.Run(tt.name, func(t *testing.T) {
76 got := IsPathExcluded(".", tt.relPath, tt.patterns)
77 if got != tt.want {
78 t.Errorf("IsPathExcluded(%q, %v) = %v, want %v", tt.relPath, tt.patterns, got, tt.want)
79 }
80 })
81 }
82}
83
84func TestMatchGitignorePattern(t *testing.T) {
85 tests := []struct {

Callers

nothing calls this directly

Calls 2

IsPathExcludedFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected