photoprism/internal/search/faces_test.go

41 lines
1.2 KiB
Go
Raw Permalink Normal View History

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) {
results, err := Faces(form.SearchFaces{Unknown: "yes", Order: "added", Markers: true})
assert.NoError(t, err)
t.Logf("Faces: %#v", results)
if len(results) == 0 {
t.Fatal("results are empty")
} else if results[0].MarkerUID == "" {
t.Fatal("marker uid is empty")
}
})
2021-09-20 13:12:28 +02:00
t.Run("Search with limit", func(t *testing.T) {
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)
assert.LessOrEqual(t, 1, len(results))
2021-09-20 13:12:28 +02:00
})
t.Run("Find specific id", func(t *testing.T) {
results, err := Faces(form.SearchFaces{UID: "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) {
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))
})
}