2021-08-13 20:31:41 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-08-13 20:50:49 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
|
2021-08-13 20:31:41 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-09-03 16:14:09 +02:00
|
|
|
func TestPeople(t *testing.T) {
|
|
|
|
if results, err := People(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.LessOrEqual(t, 3, len(results))
|
|
|
|
t.Logf("people: %#v", results)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPeopleCount(t *testing.T) {
|
|
|
|
if result, err := PeopleCount(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
} else {
|
|
|
|
assert.LessOrEqual(t, 3, result)
|
|
|
|
t.Logf("there are %d people", result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-16 00:29:36 +02:00
|
|
|
func TestSubjects(t *testing.T) {
|
|
|
|
results, err := Subjects(3, 0)
|
2021-08-13 20:31:41 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-14 18:13:03 +02:00
|
|
|
assert.GreaterOrEqual(t, len(results), 1)
|
2021-08-13 20:31:41 +02:00
|
|
|
|
|
|
|
for _, val := range results {
|
2021-08-16 00:29:36 +02:00
|
|
|
assert.IsType(t, entity.Subject{}, val)
|
2021-08-13 20:31:41 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-19 23:12:51 +02:00
|
|
|
|
2021-08-28 15:26:26 +02:00
|
|
|
func TestSubjectMap(t *testing.T) {
|
|
|
|
results, err := SubjectMap()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.GreaterOrEqual(t, len(results), 1)
|
|
|
|
|
|
|
|
for _, val := range results {
|
|
|
|
assert.IsType(t, entity.Subject{}, val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-24 13:13:59 +02:00
|
|
|
func TestRemoveOrphanSubjects(t *testing.T) {
|
|
|
|
affected, err := RemoveOrphanSubjects()
|
2021-08-22 16:14:34 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, int64(1), affected)
|
2021-08-19 23:12:51 +02:00
|
|
|
}
|
2021-08-24 14:27:34 +02:00
|
|
|
|
2021-08-29 13:26:05 +02:00
|
|
|
func TestCreateMarkerSubjects(t *testing.T) {
|
|
|
|
affected, err := CreateMarkerSubjects()
|
2021-08-24 14:27:34 +02:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
2021-09-01 12:48:17 +02:00
|
|
|
assert.LessOrEqual(t, int64(0), affected)
|
2021-08-24 14:27:34 +02:00
|
|
|
}
|