2021-09-18 15:32:39 +02:00
|
|
|
package search
|
2020-05-13 10:16:12 +02:00
|
|
|
|
|
|
|
import (
|
2020-11-21 18:08:41 +01:00
|
|
|
"testing"
|
|
|
|
|
2020-05-13 10:16:12 +02:00
|
|
|
"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.AccountSearch{
|
|
|
|
Query: "",
|
|
|
|
Share: true,
|
|
|
|
Sync: true,
|
|
|
|
Status: "",
|
|
|
|
Count: 10,
|
|
|
|
Offset: 0,
|
|
|
|
Order: "",
|
|
|
|
}
|
2021-09-18 15:32:39 +02:00
|
|
|
r, err := Accounts(f)
|
2020-05-13 10:16:12 +02:00
|
|
|
|
|
|
|
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.Account{}, r)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("find accounts count 1001", func(t *testing.T) {
|
|
|
|
f := form.AccountSearch{
|
|
|
|
Query: "",
|
|
|
|
Share: false,
|
|
|
|
Sync: false,
|
2021-07-22 13:53:17 +02:00
|
|
|
Status: "refresh",
|
2020-05-13 10:16:12 +02:00
|
|
|
Count: 1001,
|
|
|
|
Offset: 0,
|
|
|
|
Order: "",
|
|
|
|
}
|
2021-09-18 15:32:39 +02:00
|
|
|
r, err := Accounts(f)
|
2020-05-13 10:16:12 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("accounts: %+v", r)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(r))
|
|
|
|
|
2020-07-13 11:11:52 +02:00
|
|
|
for _, r := range r {
|
|
|
|
assert.IsType(t, entity.Account{}, r)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("find accounts count > max results", func(t *testing.T) {
|
|
|
|
f := form.AccountSearch{
|
|
|
|
Query: "",
|
2021-07-22 13:53:17 +02:00
|
|
|
Status: "refresh",
|
2020-07-13 11:11:52 +02:00
|
|
|
Count: 100000,
|
|
|
|
Offset: 0,
|
|
|
|
Order: "",
|
|
|
|
}
|
2021-09-18 15:32:39 +02:00
|
|
|
r, err := Accounts(f)
|
2020-07-13 11:11:52 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
//t.Logf("accounts: %+v", r)
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(r))
|
|
|
|
|
2020-05-13 10:16:12 +02:00
|
|
|
for _, r := range r {
|
|
|
|
assert.IsType(t, entity.Account{}, r)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|