(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func 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 | |
| 84 | func TestMatchGitignorePattern(t *testing.T) { |
| 85 | tests := []struct { |
nothing calls this directly
no test coverage detected