photoprism/pkg/fs/dirs_test.go
Michael Mayer 99eaae0816 Backend: Import JSON metadata from Google Photos
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-07-11 16:46:29 +02:00

46 lines
920 B
Go

package fs
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDirs(t *testing.T) {
t.Run("recursive", func(t *testing.T) {
result, err := Dirs("testdata", true)
if err != nil {
t.Fatal(err)
}
expected := []string{"/directory", "/directory/subdirectory", "/linked"}
assert.Equal(t, expected, result)
})
t.Run("non-recursive", func(t *testing.T) {
result, err := Dirs("testdata", false)
if err != nil {
t.Fatal(err)
}
expected := []string{"/directory", "/linked"}
assert.Equal(t, expected, result)
})
}
func TestFindDirs(t *testing.T) {
t.Run("/directory", func(t *testing.T) {
result := FindDir([]string{"/directory", "/directory/subdirectory", "/linked"})
assert.Equal(t, "", result)
})
t.Run("./testdata", func(t *testing.T) {
result := FindDir([]string{"./testdata"})
assert.True(t, strings.HasSuffix(result, "/pkg/fs/testdata"))
})
}