photoprism/internal/search/users_test.go
Michael Mayer 0a5dce5aeb Auth: Refactor sessions API and model #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-03-09 18:45:04 +01:00

49 lines
1.2 KiB
Go

package search
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/form"
)
func TestUsers(t *testing.T) {
t.Run("Default", func(t *testing.T) {
if results, err := Users(form.SearchUsers{}); err != nil {
t.Fatal(err)
} else {
assert.LessOrEqual(t, 2, len(results))
//t.Logf("sessions: %#v", results)
}
})
t.Run("Limit", func(t *testing.T) {
if results, err := Users(form.SearchUsers{Count: 1}); err != nil {
t.Fatal(err)
} else {
assert.LessOrEqual(t, 1, len(results))
//t.Logf("sessions: %#v", results)
}
})
t.Run("Offset", func(t *testing.T) {
if results, err := Users(form.SearchUsers{Offset: 1}); err != nil {
t.Fatal(err)
} else {
assert.LessOrEqual(t, 2, len(results))
//t.Logf("sessions: %#v", results)
}
})
t.Run("SearchAlice", func(t *testing.T) {
if results, err := Users(form.SearchUsers{Count: 100, Query: "alice"}); err != nil {
t.Fatal(err)
} else {
t.Logf("users: %#v", results)
assert.LessOrEqual(t, 1, len(results))
if len(results) > 0 {
assert.Equal(t, 5, results[0].ID)
assert.Equal(t, "uqxetse3cy5eo9z2", results[0].UserUID)
assert.Equal(t, "alice", results[0].UserName)
}
}
})
}