github.com/bazelbuild/bazel-gazelle@v0.36.1-0.20240520142334-61b277ba6fed/walk/config_test.go (about)

     1  package walk
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/bmatcuk/doublestar/v4"
     7  )
     8  
     9  func TestCheckPathMatchPattern(t *testing.T) {
    10  	testCases := []struct {
    11  		pattern string
    12  		err     error
    13  	}{
    14  		{pattern: "*.pb.go", err: nil},
    15  		{pattern: "**/*.pb.go", err: nil},
    16  		{pattern: "**/*.pb.go", err: nil},
    17  		{pattern: "[]a]", err: doublestar.ErrBadPattern},
    18  		{pattern: "[c-", err: doublestar.ErrBadPattern},
    19  	}
    20  
    21  	for _, testCase := range testCases {
    22  		if want, got := testCase.err, checkPathMatchPattern(testCase.pattern); want != got {
    23  			t.Errorf("checkPathMatchPattern %q: got %q want %q", testCase.pattern, got, want)
    24  		}
    25  	}
    26  }