2020-05-24 22:16:06 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFoldersByPath(t *testing.T) {
|
|
|
|
t.Run("root", func(t *testing.T) {
|
2020-05-27 13:40:21 +02:00
|
|
|
folders, err := FoldersByPath(entity.RootDefault, "testdata", "", false)
|
2020-05-24 22:16:06 +02:00
|
|
|
|
|
|
|
t.Logf("folders: %+v", folders)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Len(t, folders, 1)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("subdirectory", func(t *testing.T) {
|
2020-05-27 13:40:21 +02:00
|
|
|
folders, err := FoldersByPath(entity.RootDefault, "testdata", "directory", false)
|
2020-05-24 22:16:06 +02:00
|
|
|
|
|
|
|
t.Logf("folders: %+v", folders)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Len(t, folders, 2)
|
|
|
|
})
|
|
|
|
}
|
2020-05-30 15:42:04 +02:00
|
|
|
|
|
|
|
func TestAlbumFolders(t *testing.T) {
|
|
|
|
t.Run("root", func(t *testing.T) {
|
|
|
|
folders, err := AlbumFolders(1)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.Len(t, folders, 1)
|
|
|
|
|
|
|
|
t.Logf("folders: %+v", folders)
|
|
|
|
})
|
|
|
|
}
|