photoprism/internal/search/accounts_test.go
Michael Mayer e3bb8b19dd Routing: Prefix frontend UI routes with /library #840 #2466
Also improves migrations and updates the db schema docs.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-15 21:54:11 +02:00

83 lines
1.4 KiB
Go

package search
import (
"testing"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/internal/form"
"github.com/stretchr/testify/assert"
)
func TestAccounts(t *testing.T) {
t.Run("find accounts", func(t *testing.T) {
f := form.SearchServices{
Query: "",
Share: true,
Sync: true,
Status: "",
Count: 10,
Offset: 0,
Order: "",
}
r, err := Accounts(f)
if err != nil {
t.Fatal(err)
}
//t.Logf("accounts: %+v", r)
assert.LessOrEqual(t, 1, len(r))
for _, r := range r {
assert.IsType(t, entity.Service{}, r)
}
})
t.Run("find accounts count 1001", func(t *testing.T) {
f := form.SearchServices{
Query: "",
Share: false,
Sync: false,
Status: "refresh",
Count: 1001,
Offset: 0,
Order: "",
}
r, err := Accounts(f)
if err != nil {
t.Fatal(err)
}
//t.Logf("accounts: %+v", r)
assert.LessOrEqual(t, 1, len(r))
for _, r := range r {
assert.IsType(t, entity.Service{}, r)
}
})
t.Run("find accounts count > max results", func(t *testing.T) {
f := form.SearchServices{
Query: "",
Status: "refresh",
Count: 100000,
Offset: 0,
Order: "",
}
r, err := Accounts(f)
if err != nil {
t.Fatal(err)
}
//t.Logf("accounts: %+v", r)
assert.LessOrEqual(t, 1, len(r))
for _, r := range r {
assert.IsType(t, entity.Service{}, r)
}
})
}