MCPcopy
hub / github.com/sqlc-dev/sqlc / TestGlobPattern

Function TestGlobPattern

internal/sql/sqlpath/read_test.go:200–243  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestGlobPattern(t *testing.T) {
201 // Arrange
202 tests := []struct {
203 pattern string
204 expected []string
205 }{
206 {
207 pattern: "testdata/glob/*/queries",
208 expected: []string{
209 filepath.Join("testdata", "glob", "sub1", "queries", "file1.sql"),
210 filepath.Join("testdata", "glob", "sub2", "queries", "file2.sql"),
211 filepath.Join("testdata", "glob", "sub3", "queries", "file3.sql"),
212 filepath.Join("testdata", "glob", "sub3", "queries", "file4.sql"),
213 },
214 },
215 {
216 pattern: "testdata/glob/sub3/queries/file?.sql",
217 expected: []string{
218 filepath.Join("testdata", "glob", "sub3", "queries", "file3.sql"),
219 filepath.Join("testdata", "glob", "sub3", "queries", "file4.sql"),
220 },
221 },
222 {
223 pattern: "testdata/glob/sub3/queries/file[1-5].sql",
224 expected: []string{
225 filepath.Join("testdata", "glob", "sub3", "queries", "file3.sql"),
226 filepath.Join("testdata", "glob", "sub3", "queries", "file4.sql"),
227 },
228 },
229 }
230
231 for _, test := range tests {
232 // Act
233 result, err := Glob([]string{test.pattern})
234
235 // Assert
236 if !cmp.Equal(result, test.expected) {
237 t.Errorf("Pattern %v: Expected %v, but got %v", test.pattern, test.expected, result)
238 }
239 if err != nil {
240 t.Errorf("Pattern %v: Expected no error, but got %v", test.pattern, err)
241 }
242 }
243}

Callers

nothing calls this directly

Calls 3

GlobFunction · 0.85
JoinMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected