Skip to content

Commit

Permalink
test: added failing tests (#8)
Browse files Browse the repository at this point in the history
* test: added failing tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: quotemeta

* fix: test cases

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Nov 9, 2020
1 parent 6c2892c commit b27e0ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ func TestGlob(t *testing.T) { // nolint:funlen
require.Equal(t, []string{"a/b/c"}, matches)
})

t.Run("direct match wildcard", func(t *testing.T) {
matches, err := Glob(QuoteMeta("a/b/c{a"), WithFs(testFs(t, []string{
"./a/nope.txt",
"a/b/c{a",
}, nil)))
require.NoError(t, err)
require.Equal(t, []string{"a/b/c{a"}, matches)
})

t.Run("direct no match", func(t *testing.T) {
matches, err := Glob("a/b/d", WithFs(testFs(t, []string{
"./a/nope.txt",
Expand All @@ -145,6 +154,15 @@ func TestGlob(t *testing.T) { // nolint:funlen
require.Empty(t, matches)
})

t.Run("direct no match escaped wildcards", func(t *testing.T) {
matches, err := Glob(QuoteMeta("a/b/c{a"), WithFs(testFs(t, []string{
"./a/nope.txt",
"./a/b/dc",
}, nil)))
require.EqualError(t, err, "matching \"a/b/c{a\": file does not exist")
require.Empty(t, matches)
})

t.Run("no matches", func(t *testing.T) {
matches, err := Glob("z/*", WithFs(testFs(t, []string{
"./a/nope.txt",
Expand Down

0 comments on commit b27e0ce

Please sign in to comment.