Skip to content

Commit

Permalink
test: more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 6, 2020
1 parent e2f9e80 commit bfa3bc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func GlobWithFs(fs afero.Fs, pattern string) ([]string, error) {

prefix, err := staticPrefix(pattern)
if err != nil {
return nil, fmt.Errorf("determine static prefix: %w", err)
return nil, fmt.Errorf("cannot determine static prefix: %w", err)
}

prefixInfo, err := fs.Stat(prefix)
Expand Down
9 changes: 9 additions & 0 deletions glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ func TestGlob(t *testing.T) {
require.Equal(t, []string{"a/b/c"}, matches)
})

t.Run("direct no match", func(t *testing.T) {
matches, err := globInMemoryFs("a/b/d", []string{
"./a/nope.txt",
"./a/b/dc",
})
require.NoError(t, err)
require.Equal(t, []string{}, matches)
})

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

0 comments on commit bfa3bc5

Please sign in to comment.