2021-09-18 15:32:39 +02:00
|
|
|
package search
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/form"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFaces(t *testing.T) {
|
|
|
|
t.Run("Unknown", func(t *testing.T) {
|
2021-11-26 14:28:50 +01:00
|
|
|
results, err := Faces(form.SearchFaces{Unknown: "yes", Order: "added", Markers: true})
|
2021-09-18 15:32:39 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
t.Logf("Faces: %#v", results)
|
2021-10-05 20:28:08 +02:00
|
|
|
if len(results) == 0 {
|
|
|
|
t.Fatal("results are empty")
|
2021-10-06 11:19:07 +02:00
|
|
|
} else if results[0].MarkerUID == "" {
|
2021-10-05 20:28:08 +02:00
|
|
|
t.Fatal("marker uid is empty")
|
|
|
|
}
|
2021-09-18 15:32:39 +02:00
|
|
|
})
|
2021-09-20 13:12:28 +02:00
|
|
|
t.Run("Search with limit", func(t *testing.T) {
|
2021-11-26 14:28:50 +01:00
|
|
|
results, err := Faces(form.SearchFaces{Offset: 3, Order: "subject", Markers: true})
|
2021-09-20 13:12:28 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
t.Logf("Faces: %#v", results)
|
2021-10-06 11:19:07 +02:00
|
|
|
assert.LessOrEqual(t, 1, len(results))
|
2021-09-20 13:12:28 +02:00
|
|
|
})
|
|
|
|
t.Run("Find specific id", func(t *testing.T) {
|
2021-11-26 14:28:50 +01:00
|
|
|
results, err := Faces(form.SearchFaces{ID: "PN6QO5INYTUSAATOFL43LL2ABAV5ACZK", Markers: true})
|
2021-09-20 13:12:28 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
t.Logf("Faces: %#v", results)
|
|
|
|
assert.LessOrEqual(t, 1, len(results))
|
|
|
|
})
|
|
|
|
t.Run("Exclude Unknown & Hidden", func(t *testing.T) {
|
2021-11-26 14:28:50 +01:00
|
|
|
results, err := Faces(form.SearchFaces{Unknown: "no", Hidden: "yes", Order: "samples", Markers: true})
|
2021-09-20 13:12:28 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
t.Logf("Faces: %#v", results)
|
|
|
|
assert.LessOrEqual(t, 0, len(results))
|
|
|
|
})
|
2021-09-18 15:32:39 +02:00
|
|
|
}
|