Skip to content

Commit

Permalink
test: Add tests with escaped wildcards.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgeiser committed Nov 6, 2020
1 parent 39d500e commit 2364766
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,30 @@ func TestGlob(t *testing.T) {
require.NoError(t, err)
require.Empty(t, matches)
})

t.Run("escaped asterisk", func(t *testing.T) {
matches, err := globInMemoryFs("a/\\*/b", []string{
"a/a/b",
"a/*/b",
"a/**/b",
})
require.NoError(t, err)
require.Equal(t, []string{
"a/*/b",
}, matches)
})

t.Run("escaped curly braces", func(t *testing.T) {
matches, err := globInMemoryFs("\\{a,b\\}/c", []string{
"a/c",
"b/c",
"{a,b}/c",
})
require.NoError(t, err)
require.Equal(t, []string{
"{a,b}/c",
}, matches)
})
}

func globInMemoryFs(pattern string, files []string) ([]string, error) {
Expand Down

0 comments on commit 2364766

Please sign in to comment.