processor/history_ignore_test.go GO 56 lines View on github.com → Search inside
1// SPDX-License-Identifier: MIT23package processor45import (6	"strings"7	"testing"89	"github.com/go-git/go-git/v5/plumbing/format/gitignore"10)1112func TestParseIgnoreFileSkipsCommentsAndBlanks(t *testing.T) {13	body := strings.NewReader("# comment\n\nfoo\n!bar\n   \n")14	pats := parseIgnoreFile(body, nil)15	if len(pats) != 2 {16		t.Fatalf("got %d patterns, want 2", len(pats))17	}18}1920func TestHistoryIgnoreMatchesPattern(t *testing.T) {21	pat := gitignore.ParsePattern("vendor/", nil)22	h := &historyIgnore{matcher: gitignore.NewMatcher([]gitignore.Pattern{pat})}2324	if !h.Match("vendor/foo.go", false) {25		t.Errorf("vendor/foo.go should match vendor/ pattern")26	}27	if h.Match("foo.go", false) {28		t.Errorf("foo.go should not match vendor/ pattern")29	}30}3132func TestHistoryIgnoreNilSafe(t *testing.T) {33	var h *historyIgnore34	if h.Match("anything", false) {35		t.Errorf("nil matcher should match nothing")36	}37}3839func TestSplitDomain(t *testing.T) {40	cases := []struct {41		in   string42		want int43	}{44		{"", 0},45		{".", 0},46		{"a", 1},47		{"a/b/c", 3},48	}49	for _, c := range cases {50		got := splitDomain(c.in)51		if len(got) != c.want {52			t.Errorf("splitDomain(%q) = %v, want length %d", c.in, got, c.want)53		}54	}55}

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.