2021-09-18 15:32:39 +02:00
|
|
|
package search
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
import (
|
2021-09-20 23:32:35 +02:00
|
|
|
"strconv"
|
2020-05-08 15:41:01 +02:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
2020-05-08 15:41:01 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
2023-01-30 12:27:34 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/sortby"
|
2020-05-08 15:41:01 +02:00
|
|
|
)
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
func TestPhotos(t *testing.T) {
|
2022-10-02 22:09:02 +02:00
|
|
|
t.Run("OrderDuration", func(t *testing.T) {
|
|
|
|
var frm form.SearchPhotos
|
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
2023-01-30 12:27:34 +01:00
|
|
|
frm.Order = sortby.Duration
|
2022-10-02 22:09:02 +02:00
|
|
|
|
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
})
|
2023-01-30 12:27:34 +01:00
|
|
|
t.Run("OrderRandom", func(t *testing.T) {
|
|
|
|
var frm form.SearchPhotos
|
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Order = sortby.Random
|
|
|
|
|
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("OrderInvalid", func(t *testing.T) {
|
|
|
|
var frm form.SearchPhotos
|
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Order = sortby.Invalid
|
|
|
|
|
|
|
|
_, _, err := Photos(frm)
|
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
2021-09-17 15:52:25 +02:00
|
|
|
t.Run("Chinese", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-17 15:52:25 +02:00
|
|
|
|
|
|
|
frm.Query = "张"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
_, _, err := Photos(frm)
|
2021-09-17 15:52:25 +02:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
2021-09-23 14:23:00 +02:00
|
|
|
t.Run("UnknownFaces", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-23 14:23:00 +02:00
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Face = "None"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
|
|
|
results, _, err := Photos(frm)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.LessOrEqual(t, 1, len(results))
|
|
|
|
})
|
2020-05-14 14:18:28 +02:00
|
|
|
t.Run("search all", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
for _, r := range photos {
|
2021-09-18 15:32:39 +02:00
|
|
|
assert.IsType(t, Photo{}, r)
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-05-14 14:18:28 +02:00
|
|
|
t.Run("search for ID and merged", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
2024-01-05 16:31:07 +01:00
|
|
|
frm.UID = "ps6sg6be2lvl0yh7"
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Merged = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for ID with merged false", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
2024-01-05 16:31:07 +01:00
|
|
|
frm.UID = "ps6sg6be2lvl0yh7"
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Merged = false
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Run("label query dog", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "label:dog"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-23 23:46:17 +02:00
|
|
|
photos, count, err := Photos(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-09-23 23:46:17 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, PhotoResults{}, photos)
|
|
|
|
assert.Equal(t, 0, count)
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
|
|
|
t.Run("label query landscape", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
frm.Query = "label:landscape"
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
2022-08-01 15:57:19 +02:00
|
|
|
frm.Order = "relevance"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
if err != nil {
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Fatal(err)
|
2020-05-08 15:41:01 +02:00
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("invalid label query", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "label:xxx"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-23 23:46:17 +02:00
|
|
|
photos, count, err := Photos(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-09-23 23:46:17 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, PhotoResults{}, photos)
|
|
|
|
assert.Equal(t, 0, count)
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.location true", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
2023-06-29 18:35:02 +02:00
|
|
|
frm.Geo = "yes"
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-14 14:18:28 +02:00
|
|
|
})
|
|
|
|
t.Run("form.location true and keyword", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "bridge"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
2023-06-29 18:35:02 +02:00
|
|
|
frm.Geo = "yes"
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Error = false
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for keyword", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "bridge"
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for label in query", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-02-07 19:04:17 +01:00
|
|
|
frm.Query = "flower"
|
|
|
|
frm.Count = 5000
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-12-27 16:37:28 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for archived", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Archived = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for private", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Private = true
|
2020-05-18 15:45:55 +02:00
|
|
|
f.Error = true
|
2020-05-14 14:18:28 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for public", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Public = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for review", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Review = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for quality", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
2020-05-25 19:10:44 +02:00
|
|
|
f.Quality = 3
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Private = false
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for file error", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Error = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-14 14:18:28 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2022-03-28 16:25:40 +02:00
|
|
|
t.Run("form.camera- name", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
f.Camera = "Canon EOS 6D"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("camera:\"Canon EOS 6D\"", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
|
|
|
|
f.Query = "camera:\"Canon EOS 6D\""
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("form.camera- id", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-02-07 19:04:17 +01:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Query = ""
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
2022-03-24 18:30:59 +01:00
|
|
|
f.Camera = "1000003"
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 3, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.color", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
f.Color = "blue"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.favorites", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-14 19:03:12 +02:00
|
|
|
f.Query = "favorite:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.country", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "country:zz"
|
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-25 19:10:44 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2022-08-31 23:04:00 +02:00
|
|
|
})
|
|
|
|
t.Run("form.city", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.Query = "city:Mandeni"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.title", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "title:Neckarbrücke"
|
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-29 16:16:49 +02:00
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
|
|
|
|
})
|
|
|
|
t.Run("form.keywords", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-29 16:16:49 +02:00
|
|
|
f.Query = "keywords:bridge"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-29 16:16:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 4)
|
|
|
|
})
|
2021-09-18 15:32:39 +02:00
|
|
|
t.Run("form.face", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-09-18 15:32:39 +02:00
|
|
|
f.Query = "face:PN6QO5INYTUSAATOFL43LL2ABAV5ACZK"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
|
|
|
})
|
2021-08-29 16:16:49 +02:00
|
|
|
t.Run("form.subject", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2024-01-05 16:31:07 +01:00
|
|
|
f.Query = "subject:js6sg6b1qekk9jx8"
|
2021-08-29 16:16:49 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-29 16:16:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
2021-08-29 16:16:49 +02:00
|
|
|
})
|
|
|
|
t.Run("form.subjects", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-29 16:16:49 +02:00
|
|
|
f.Query = "subjects:John"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-29 16:16:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("form.people", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-29 16:16:49 +02:00
|
|
|
f.Query = "people:John"
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-29 16:16:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
t.Run("form.hash", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "hash:2cad9168fa6acc5c5c2965ddf6ec465ca42fd818"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
//t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("form.portrait", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Query = "portrait:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-07-18 13:09:22 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
t.Run("form.mono", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Query = "mono:true"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2020-05-14 14:18:28 +02:00
|
|
|
f.Archived = true
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-14 14:18:28 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Run("form.chroma:25", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Query = "chroma:25"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Run("form.chroma <9", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "chroma:4"
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Count = 3
|
|
|
|
f.Offset = 0
|
2020-05-18 15:45:55 +02:00
|
|
|
f.Error = true
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2023-10-21 16:33:00 +02:00
|
|
|
t.Run("form.f", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2023-10-21 16:33:00 +02:00
|
|
|
f.Query = "F:5-100"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Order = "oldest"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2023-10-21 16:33:00 +02:00
|
|
|
t.Run("form.f", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2023-10-21 16:33:00 +02:00
|
|
|
f.Query = "F:0-2"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Order = "newest"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2020-05-08 15:41:01 +02:00
|
|
|
})
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Run("form.Lat and form.Lng", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2023-09-20 17:42:38 +02:00
|
|
|
f.Query = "Lat:33.45343166666667 Lng:25.764711666666667 Dist:4000"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Order = "imported"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
|
|
|
})
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Run("form.Lat and form.Lng and Dist:6000", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Query = "Lat:33.45343166666667 Lng:25.764711666666667 Dist:6000"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Order = "imported"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
2023-07-27 16:09:23 +02:00
|
|
|
})
|
2023-09-20 03:18:30 +02:00
|
|
|
t.Run("latlng:33.453431,-180.0,49.519234,180.0", func(t *testing.T) {
|
2023-07-27 16:09:23 +02:00
|
|
|
var f form.SearchPhotos
|
2023-09-20 03:18:30 +02:00
|
|
|
f.Query = "latlng:33.453431,-180.0,49.519234,180.0"
|
2023-07-27 16:09:23 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
f.Order = "imported"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range photos {
|
|
|
|
assert.GreaterOrEqual(t, float32(49.519234), p.PhotoLat)
|
|
|
|
assert.LessOrEqual(t, float32(33.45343166666667), p.PhotoLat)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
|
|
|
|
|
|
|
})
|
2023-09-20 03:18:30 +02:00
|
|
|
t.Run("latlng:0.00,-30.123.0,49.519234,9.1001234", func(t *testing.T) {
|
2023-07-27 16:09:23 +02:00
|
|
|
var f form.SearchPhotos
|
2023-09-20 03:18:30 +02:00
|
|
|
f.Query = "latlng:0.00,-30.123.0,49.519234,9.1001234"
|
2023-07-27 16:09:23 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
f.Order = "imported"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range photos {
|
|
|
|
assert.GreaterOrEqual(t, float32(49.519234), p.PhotoLat)
|
|
|
|
assert.LessOrEqual(t, float32(0.00), p.PhotoLat)
|
|
|
|
assert.GreaterOrEqual(t, float32(9.1001234), p.PhotoLng)
|
|
|
|
assert.LessOrEqual(t, float32(-30.123), p.PhotoLng)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 10, len(photos))
|
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
|
|
|
t.Run("form.Before and form.After Order:relevance", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Query = "Before:2016-01-01 After:2013-01-01"
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
|
|
|
f.Merged = true
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Order = "relevance"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-13 19:47:17 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-18 15:45:55 +02:00
|
|
|
assert.LessOrEqual(t, 2, len(photos))
|
2020-05-13 19:47:17 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for diff", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = "Diff:800"
|
|
|
|
f.Count = 5000
|
2020-05-08 15:41:01 +02:00
|
|
|
f.Offset = 0
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-13 19:47:17 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2022-03-24 18:30:59 +01:00
|
|
|
t.Run("search for camera name", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 1
|
|
|
|
f.Offset = 0
|
|
|
|
f.Camera = "canon"
|
|
|
|
f.Lens = ""
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for lens name", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 1
|
|
|
|
f.Offset = 0
|
|
|
|
f.Camera = ""
|
|
|
|
f.Lens = "apple"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2022-03-28 16:25:40 +02:00
|
|
|
t.Run("search for full lens name", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.Query = ""
|
|
|
|
f.Count = 1
|
|
|
|
f.Offset = 0
|
|
|
|
f.Camera = ""
|
|
|
|
f.Lens = "Apple F380"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
t.Run("search for full lens name using query", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.Query = "lens:\"Apple F380\""
|
|
|
|
f.Count = 1
|
|
|
|
f.Offset = 0
|
|
|
|
f.Camera = ""
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-13 19:47:17 +02:00
|
|
|
t.Run("search for lens, month, year, album", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-13 19:47:17 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Count = 5000
|
|
|
|
f.Offset = 0
|
2022-03-24 18:30:59 +01:00
|
|
|
f.Lens = "1000000"
|
2021-09-20 23:32:35 +02:00
|
|
|
f.Month = strconv.Itoa(7)
|
|
|
|
f.Year = strconv.Itoa(2790)
|
2024-01-05 16:31:07 +01:00
|
|
|
f.Album = "as6sg6bxpogaaba8"
|
2020-05-13 19:47:17 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-08 15:41:01 +02:00
|
|
|
|
2020-05-13 19:47:17 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2021-08-29 16:16:49 +02:00
|
|
|
t.Run("albums", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-29 16:16:49 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Albums = "Berlin"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-29 16:16:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
t.Run("f.album", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
f.Query = ""
|
|
|
|
f.Album = "Berlin"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-29 18:04:30 +02:00
|
|
|
t.Run("search for state", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-29 18:04:30 +02:00
|
|
|
f.State = "KwaZulu-Natal"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-29 18:04:30 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2022-08-31 23:04:00 +02:00
|
|
|
t.Run("search for city", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
f.City = "Mandeni"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-05-29 18:04:30 +02:00
|
|
|
t.Run("search for category", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-05-29 18:04:30 +02:00
|
|
|
f.Category = "botanical garden"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-29 18:04:30 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for labels", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-12-14 22:57:07 +01:00
|
|
|
f.Label = "botanical-garden|nature|landscape|park"
|
2020-05-29 18:04:30 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-05-29 18:04:30 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
t.Run("search for primary files", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Primary = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search for landscape", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Query = "landscape"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("search with multiple parameters", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Hidden = true
|
2023-08-16 10:34:55 +02:00
|
|
|
f.Scan = "true"
|
2021-09-20 23:32:35 +02:00
|
|
|
f.Year = "2010"
|
|
|
|
f.Day = "1"
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Photo = true
|
|
|
|
f.Name = "xxx"
|
|
|
|
f.Original = "xxyy"
|
|
|
|
f.Path = "/xxx/xxx/"
|
2023-01-30 12:27:34 +01:00
|
|
|
f.Order = sortby.Name
|
2020-07-13 13:12:32 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.IsType(t, PhotoResults{}, photos)
|
|
|
|
})
|
|
|
|
t.Run("search with multiple parameters", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Hidden = true
|
2023-08-16 10:34:55 +02:00
|
|
|
f.Scan = "true"
|
2021-09-20 23:32:35 +02:00
|
|
|
f.Year = strconv.Itoa(2010)
|
|
|
|
f.Day = strconv.Itoa(1)
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Video = true
|
|
|
|
f.Name = "xxx"
|
|
|
|
f.Original = "xxyy"
|
2020-12-14 22:57:07 +01:00
|
|
|
f.Path = "/xxx|xxx"
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Type = "mp4"
|
2021-03-03 11:49:32 +01:00
|
|
|
f.Stackable = true
|
2020-07-13 13:12:32 +02:00
|
|
|
f.Unsorted = true
|
|
|
|
f.Filter = ""
|
2023-01-30 12:27:34 +01:00
|
|
|
f.Order = sortby.Added
|
2020-07-13 13:12:32 +02:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2020-07-13 13:12:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.IsType(t, PhotoResults{}, photos)
|
|
|
|
})
|
2021-03-03 11:49:32 +01:00
|
|
|
t.Run("search all recently edited", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
2023-01-30 12:27:34 +01:00
|
|
|
frm.Order = sortby.Edited
|
2021-03-03 11:49:32 +01:00
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
|
|
|
|
for _, r := range photos {
|
2021-09-18 15:32:39 +02:00
|
|
|
assert.IsType(t, Photo{}, r)
|
2021-03-03 11:49:32 +01:00
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("search unstacked panoramas", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Panorama = true
|
|
|
|
frm.Stackable = false
|
|
|
|
frm.Unstacked = true
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
|
|
|
|
for _, r := range photos {
|
2021-09-18 15:32:39 +02:00
|
|
|
assert.IsType(t, Photo{}, r)
|
2021-03-03 11:49:32 +01:00
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("Or search", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
frm.Name = "xxx|PhotoWithEditedAt"
|
2021-08-17 16:41:18 +02:00
|
|
|
frm.Filename = "xxx|2007/12/PhotoWithEditedAt.jpg"
|
2021-03-03 11:49:32 +01:00
|
|
|
frm.Title = "xxx|photowitheditedatdate"
|
|
|
|
frm.Hash = "xxx|pcad9a68fa6acc5c5ba965adf6ec465ca42fd887"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(frm)
|
2021-03-03 11:49:32 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-05-25 11:55:44 +02:00
|
|
|
|
2021-03-03 11:49:32 +01:00
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
|
|
|
|
for _, r := range photos {
|
2021-09-18 15:32:39 +02:00
|
|
|
assert.IsType(t, Photo{}, r)
|
2021-03-03 11:49:32 +01:00
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-05-26 10:46:32 +02:00
|
|
|
t.Run("faces", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-05-26 10:46:32 +02:00
|
|
|
f.Query = "faces:true"
|
2021-05-25 11:55:44 +02:00
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
2021-03-03 11:49:32 +01:00
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-05-25 11:55:44 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-29 16:16:49 +02:00
|
|
|
assert.GreaterOrEqual(t, len(photos), 3)
|
2021-05-25 11:55:44 +02:00
|
|
|
})
|
2021-08-31 17:18:48 +02:00
|
|
|
t.Run("faces:yes", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Faces = "Yes"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 3)
|
|
|
|
})
|
|
|
|
t.Run("faces:no", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Faces = "No"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 9)
|
|
|
|
})
|
2021-10-22 18:00:09 +02:00
|
|
|
t.Run("f.face yes", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-10-22 18:00:09 +02:00
|
|
|
f.Face = "yes"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 9)
|
|
|
|
})
|
2021-08-31 17:18:48 +02:00
|
|
|
t.Run("faces:2", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Faces = "2"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("Subject", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
2024-01-05 16:31:07 +01:00
|
|
|
frm.Subject = "js6sg6b1qekk9jx8"
|
2021-09-20 14:05:44 +02:00
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.CameraID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-09-29 20:09:34 +02:00
|
|
|
t.Run("NewFaces", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-29 20:09:34 +02:00
|
|
|
|
|
|
|
frm.Face = "new"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-29 20:09:34 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("query: videos", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "videos"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
2021-11-30 12:37:43 +01:00
|
|
|
|
2021-11-30 15:38:24 +01:00
|
|
|
if r.PhotoType != "video" {
|
|
|
|
t.Error("type should be video only")
|
2021-11-30 12:37:43 +01:00
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
t.Run("query: video", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Query = "video"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
2021-11-30 12:37:43 +01:00
|
|
|
|
2021-11-30 15:38:24 +01:00
|
|
|
if r.PhotoType != "video" {
|
|
|
|
t.Error("type should be video only")
|
2021-11-30 12:37:43 +01:00
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: live", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Query = "live"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "live", r.PhotoType)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.live", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Live = true
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "live", r.PhotoType)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: raws", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Query = "raws"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "raw", r.PhotoType)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("f.Raw", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Raw = true
|
|
|
|
frm.Query = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, "raw", r.PhotoType)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("query: faces", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "faces"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.LessOrEqual(t, 1, r.PhotoFaces)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
t.Run("query: faces", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Query = "faces:new"
|
|
|
|
frm.Face = ""
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2022-08-01 15:57:19 +02:00
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.LessOrEqual(t, 1, r.PhotoFaces)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-09-20 14:05:44 +02:00
|
|
|
t.Run("query: people", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "people"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.LessOrEqual(t, 1, r.PhotoFaces)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: favorites", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "favorites"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.True(t, r.PhotoFavorite)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: stacks", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "stacks"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: panoramas", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "panoramas"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, true, r.PhotoPanorama)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: scans", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "scans"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.Equal(t, true, r.PhotoScan)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("query: monochrome", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-09-20 14:05:44 +02:00
|
|
|
|
|
|
|
frm.Query = "monochrome"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-20 14:05:44 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
t.Run("query: mono", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var frm form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
frm.Query = "mono"
|
|
|
|
frm.Count = 10
|
|
|
|
frm.Offset = 0
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := frm.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-10-22 16:03:50 +02:00
|
|
|
photos, _, err := Photos(frm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(photos))
|
|
|
|
|
|
|
|
for _, r := range photos {
|
|
|
|
assert.IsType(t, Photo{}, r)
|
|
|
|
assert.NotEmpty(t, r.ID)
|
|
|
|
assert.NotEmpty(t, r.LensID)
|
|
|
|
|
|
|
|
if fix, ok := entity.PhotoFixtures[r.PhotoName]; ok {
|
|
|
|
assert.Equal(t, fix.PhotoName, r.PhotoName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2021-08-31 17:18:48 +02:00
|
|
|
t.Run("filename", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Filename = "1990/04/Quality1FavoriteTrue.jpg"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 1)
|
|
|
|
})
|
|
|
|
t.Run("original name or original name", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Original = "my-videos/IMG_88888" + "|" + "Vacation/exampleFileNameOriginal"
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 2)
|
|
|
|
})
|
|
|
|
t.Run("Stack", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-08-31 17:18:48 +02:00
|
|
|
f.Stack = true
|
|
|
|
|
2021-09-18 15:32:39 +02:00
|
|
|
photos, _, err := Photos(f)
|
2021-08-31 17:18:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(photos), 2)
|
|
|
|
})
|
2021-09-21 11:04:43 +02:00
|
|
|
t.Run("keywords:kuh|bridge > keywords:bridge&kuh", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
f.Query = "keywords:kuh|bridge"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
f.Query = "keywords:bridge&kuh"
|
|
|
|
|
|
|
|
photos2, _, err2 := Photos(f)
|
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Greater(t, len(photos), len(photos2))
|
|
|
|
})
|
2022-03-24 18:30:59 +01:00
|
|
|
t.Run("AlbumsOrSearch", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
f.Query = "albums:Holiday|Berlin"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
assert.Greater(t, len(photos), 5)
|
|
|
|
})
|
|
|
|
t.Run("AlbumsAndSearch", func(t *testing.T) {
|
|
|
|
var f form.SearchPhotos
|
|
|
|
|
|
|
|
f.Query = "albums:\"Berlin&Holiday\""
|
2021-09-21 11:04:43 +02:00
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
photos, _, err := Photos(f)
|
2021-09-21 11:04:43 +02:00
|
|
|
|
2022-03-24 18:30:59 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
2021-09-21 11:04:43 +02:00
|
|
|
}
|
2022-03-24 18:30:59 +01:00
|
|
|
assert.Greater(t, len(photos), 0)
|
2021-09-21 11:04:43 +02:00
|
|
|
})
|
2022-08-01 15:57:19 +02:00
|
|
|
t.Run("SubjectsAndOrSearch", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Subjects = "Actor A|Actress A"
|
|
|
|
|
2021-09-21 11:04:43 +02:00
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
f.Subjects = "Actor A&Actress A"
|
|
|
|
|
2021-09-21 11:04:43 +02:00
|
|
|
photos2, _, err2 := Photos(f)
|
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Greater(t, len(photos), len(photos2))
|
|
|
|
})
|
|
|
|
t.Run("people = subjects & person = subject", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
f.People = "Actor"
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2021-11-26 13:59:10 +01:00
|
|
|
var f2 form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
f2.Subjects = "Actor"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := f2.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-21 11:04:43 +02:00
|
|
|
photos2, _, err2 := Photos(f2)
|
|
|
|
|
|
|
|
if err2 != nil {
|
|
|
|
t.Fatal(err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, len(photos), len(photos2))
|
|
|
|
|
2021-11-26 13:59:10 +01:00
|
|
|
var f3 form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
|
|
|
|
f3.Person = "Actor A"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := f3.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-21 11:04:43 +02:00
|
|
|
photos3, _, err3 := Photos(f3)
|
|
|
|
|
|
|
|
if err3 != nil {
|
|
|
|
t.Fatal(err3)
|
|
|
|
}
|
|
|
|
|
2021-11-26 13:59:10 +01:00
|
|
|
var f4 form.SearchPhotos
|
2021-09-21 11:04:43 +02:00
|
|
|
f4.Subject = "Actor A"
|
|
|
|
|
2022-08-01 15:57:19 +02:00
|
|
|
// Parse query string and filter.
|
|
|
|
if err := f4.ParseQueryString(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-21 11:04:43 +02:00
|
|
|
photos4, _, err4 := Photos(f4)
|
|
|
|
|
|
|
|
if err4 != nil {
|
|
|
|
t.Fatal(err4)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, len(photos3), len(photos4))
|
|
|
|
assert.Equal(t, len(photos), len(photos4))
|
|
|
|
})
|
2021-10-22 16:03:50 +02:00
|
|
|
|
|
|
|
t.Run("Search in Title", func(t *testing.T) {
|
2021-11-26 13:59:10 +01:00
|
|
|
var f form.SearchPhotos
|
2021-10-22 16:03:50 +02:00
|
|
|
f.Query = "N"
|
|
|
|
f.Title = ""
|
|
|
|
f.Count = 10
|
|
|
|
f.Offset = 0
|
|
|
|
|
|
|
|
photos, _, err := Photos(f)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Logf("results: %+v", photos)
|
|
|
|
assert.Equal(t, 1, len(photos))
|
|
|
|
assert.Equal(t, photos[0].PhotoTitle, "Neckarbrücke")
|
|
|
|
})
|
2020-05-08 15:41:01 +02:00
|
|
|
}
|