2020-05-24 22:16:06 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
func TestFolderCoverByUID(t *testing.T) {
|
|
|
|
t.Run("1990/04", func(t *testing.T) {
|
|
|
|
if result, err := FolderCoverByUID("dqo63pn2f87f02xj"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else if result.FileUID == "" {
|
|
|
|
t.Fatal("result must not be empty")
|
|
|
|
} else if result.FileUID != "ft2es49w15bnlqdw" {
|
|
|
|
t.Errorf("wrong result: %#v", result)
|
|
|
|
}
|
|
|
|
})
|
2021-03-10 11:30:26 +01:00
|
|
|
t.Run("2007/12", func(t *testing.T) {
|
|
|
|
if result, err := FolderCoverByUID("dqo63pn2f87f02oi"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else if result.FileUID == "" {
|
|
|
|
t.Fatal("result must not be empty")
|
|
|
|
} else if result.FileUID != "ft2es49qhhinlplk" {
|
|
|
|
t.Errorf("wrong result: %#v", result)
|
|
|
|
}
|
|
|
|
})
|
2021-02-07 19:04:17 +01:00
|
|
|
}
|
|
|
|
|
2020-05-24 22:16:06 +02:00
|
|
|
func TestFoldersByPath(t *testing.T) {
|
|
|
|
t.Run("root", func(t *testing.T) {
|
2020-06-07 10:09:35 +02:00
|
|
|
folders, err := FoldersByPath(entity.RootOriginals, "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-06-07 10:09:35 +02:00
|
|
|
folders, err := FoldersByPath(entity.RootOriginals, "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)
|
|
|
|
}
|
2021-03-10 11:30:26 +01:00
|
|
|
assert.GreaterOrEqual(t, len(folders), 1)
|
2020-05-30 15:42:04 +02:00
|
|
|
|
|
|
|
t.Logf("folders: %+v", folders)
|
|
|
|
})
|
|
|
|
}
|
2020-12-09 21:44:39 +01:00
|
|
|
|
|
|
|
func TestUpdateFolderDates(t *testing.T) {
|
|
|
|
t.Run("success", func(t *testing.T) {
|
|
|
|
if err := UpdateFolderDates(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
})
|
2020-12-09 21:49:41 +01:00
|
|
|
}
|