2021-08-14 18:13:03 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFaces(t *testing.T) {
|
|
|
|
results, err := Faces(true)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-14 18:16:47 +02:00
|
|
|
assert.GreaterOrEqual(t, len(results), 1)
|
2021-08-14 18:13:03 +02:00
|
|
|
|
|
|
|
for _, val := range results {
|
|
|
|
assert.IsType(t, entity.Face{}, val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMatchKnownFaces(t *testing.T) {
|
|
|
|
const faceFixtureId = uint(6)
|
|
|
|
|
|
|
|
if m, err := MarkerByID(faceFixtureId); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.Empty(t, m.RefUID)
|
|
|
|
}
|
|
|
|
|
|
|
|
affected, err := MatchKnownFaces()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, int64(1), affected)
|
|
|
|
|
|
|
|
if m, err := MarkerByID(faceFixtureId); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.Equal(t, "rqu0xs11qekk9jx8", m.RefUID)
|
|
|
|
}
|
|
|
|
}
|