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

Function TestIsPathExcluded

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

Source from the content-addressed store, hash-verified

108}
109
110func TestIsPathExcluded(t *testing.T) {
111 tests := []struct {
112 name string
113 relPath string
114 patterns []string
115 want bool
116 }{
117 {"hardcoded dir .git", ".git", nil, true},
118 {"hardcoded dir prefix", ".git/config", nil, true},
119 {"node_modules dir pattern", "node_modules/foo.js", []string{"node_modules/"}, true},
120 {"gitignore pattern match", "debug.log", []string{"*.log"}, true},
121 {"no match", "main.go", []string{"*.log"}, false},
122 {"no patterns", "main.go", nil, false},
123 }
124 for _, tt := range tests {
125 t.Run(tt.name, func(t *testing.T) {
126 got := IsPathExcluded(".", tt.relPath, tt.patterns)
127 if got != tt.want {
128 t.Errorf("IsPathExcluded(%q, %v) = %v, want %v", tt.relPath, tt.patterns, got, tt.want)
129 }
130 })
131 }
132}
133
134func TestIsPathExcluded_DirectoryPatterns(t *testing.T) {
135 tests := []struct {

Callers

nothing calls this directly

Calls 2

IsPathExcludedFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected