Skip to content

Commit

Permalink
test: add tests for absolute paths
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <[email protected]>
  • Loading branch information
sagikazarmark committed Jun 4, 2024
1 parent 3e9b38c commit e6ab3fd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package locafero
import (
"fmt"
"path"
"path/filepath"
"testing"

"github.com/spf13/afero"
Expand Down Expand Up @@ -287,3 +288,35 @@ func TestFinder_Find_RelativePaths(t *testing.T) {

assert.Equal(t, expected, results)
}

func TestFinder_Find_AbsolutePaths(t *testing.T) {
abs := func(t *testing.T, s string) string {
t.Helper()

a, err := filepath.Abs(s)
require.NoError(t, err)

return a
}

fsys := afero.NewOsFs()

finder := Finder{
Paths: []string{
abs(t, "testdata/home/user"),
abs(t, "testdata/etc"),
},
Names: []string{"config.*"},
Type: FileTypeFile,
}

results, err := finder.Find(fsys)
require.NoError(t, err)

expected := []string{
abs(t, "testdata/home/user/config.yaml"),
abs(t, "testdata/etc/config.yaml"),
}

assert.Equal(t, expected, results)
}

0 comments on commit e6ab3fd

Please sign in to comment.