ad9167360d
* Import: Implement "add to album" in backend #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Import: Implement "add to album" in frontend #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Add OriginalName to photo search result Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Add json tags to PhotoName and PhotoPath Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Photo: Use EstimateCountry() in UpdateLocation() Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Photo: Set OriginalName earlier while indexing Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Ignore whitespace when stripping sequence from filename #335 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Fix labels count for SQLite Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Import: Show name of new albums #246 Signed-off-by: Michael Mayer <michael@liquidbytes.net> * Frontend: Add acceptance test files Co-authored-by: Michael Mayer <michael@liquidbytes.net>
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package query
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPhotoSelection(t *testing.T) {
|
|
t.Run("no items selected", func(t *testing.T) {
|
|
f := form.Selection{
|
|
Photos: []string{},
|
|
}
|
|
|
|
r, err := PhotoSelection(f)
|
|
|
|
assert.Equal(t, "no items selected", err.Error())
|
|
assert.Empty(t, r)
|
|
})
|
|
t.Run("photos selected", func(t *testing.T) {
|
|
f := form.Selection{
|
|
Photos: []string{"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8"},
|
|
}
|
|
|
|
r, err := PhotoSelection(f)
|
|
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
assert.Equal(t, 2, len(r))
|
|
assert.IsType(t, entity.Photos{}, r)
|
|
})
|
|
}
|
|
|
|
func TestFileSelection(t *testing.T) {
|
|
t.Run("no items selected", func(t *testing.T) {
|
|
f := form.Selection{
|
|
Photos: []string{},
|
|
}
|
|
|
|
r, err := FileSelection(f)
|
|
|
|
assert.Equal(t, "no items selected", err.Error())
|
|
assert.Empty(t, r)
|
|
})
|
|
t.Run("files selected", func(t *testing.T) {
|
|
f := form.Selection{
|
|
Photos: []string{"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8"},
|
|
}
|
|
|
|
r, err := FileSelection(f)
|
|
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
assert.Equal(t, 3, len(r))
|
|
assert.IsType(t, entity.Files{}, r)
|
|
})
|
|
}
|