Skip to content

Commit

Permalink
test: improve test a bit
Browse files Browse the repository at this point in the history
refs #24
  • Loading branch information
caarlos0 committed Feb 10, 2022
1 parent 5824e57 commit 9de076d
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions glob_test.go
Expand Up @@ -458,23 +458,26 @@ func TestGlob(t *testing.T) { // nolint:funlen
fsPath = testFS.Path()
}

workingSymlink := filepath.Join(fsPath, "b")
brokenSymlink := filepath.Join(fsPath, "c")
err := os.Symlink("a", workingSymlink)
require.NoError(t, err)
err = os.Symlink("non-existent", brokenSymlink)
require.NoError(t, err)

matches, err := Glob(workingSymlink)
require.NoError(t, err)
require.Equal(t, []string{
workingSymlink,
}, matches)
matches, err = Glob(brokenSymlink)
require.NoError(t, err)
require.Equal(t, []string{
brokenSymlink,
}, matches)
t.Run("good", func(t *testing.T) {
workingSymlink := filepath.Join(fsPath, "b")
require.NoError(t, os.Symlink("a", workingSymlink))
matches, err := Glob(workingSymlink)
require.NoError(t, err)
require.Equal(t, []string{
workingSymlink,
}, matches)
})

t.Run("broken", func(t *testing.T) {
brokenSymlink := filepath.Join(fsPath, "c")
require.NoError(t, os.Symlink("non-existent", brokenSymlink))

matches, err := Glob(brokenSymlink)
require.NoError(t, err)
require.Equal(t, []string{
brokenSymlink,
}, matches)
})
})
}

Expand Down

0 comments on commit 9de076d

Please sign in to comment.