Backend: Add tests to internal/query
This commit is contained in:
parent
156c7b295e
commit
6c9b994664
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFileShares(t *testing.T) {
|
||||
|
@ -21,21 +22,18 @@ func TestFileShares(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExpiredFileShares(t *testing.T) {
|
||||
//TODO Find way to not overwrite updated at in test db
|
||||
/*t.Run("expired file share exists", func(t *testing.T) {
|
||||
t.Log(entity.AccountFixtureWebdavDummy.ShareExpires)
|
||||
time.Sleep(10 * time.Second)
|
||||
t.Run("expired file share exists", func(t *testing.T) {
|
||||
time.Sleep(2 * time.Second)
|
||||
r, err := ExpiredFileShares(entity.AccountFixtureWebdavDummy)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("%+v", r)
|
||||
|
||||
assert.LessOrEqual(t, 1, len(r))
|
||||
for _, r := range r {
|
||||
assert.IsType(t, entity.FileShare{}, r)
|
||||
}
|
||||
})*/
|
||||
})
|
||||
t.Run("expired file does not exists", func(t *testing.T) {
|
||||
r, err := ExpiredFileShares(entity.AccountFixtureWebdavDummy2)
|
||||
if err != nil {
|
||||
|
|
|
@ -35,6 +35,32 @@ func TestLabels(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("search for cow", func(t *testing.T) {
|
||||
query := form.NewLabelSearch("Query:cow Count:1005 Order:slug")
|
||||
result, err := Labels(query)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Logf("results: %+v", result)
|
||||
|
||||
assert.LessOrEqual(t, 1, len(result))
|
||||
|
||||
for _, r := range result {
|
||||
assert.IsType(t, LabelResult{}, r)
|
||||
assert.NotEmpty(t, r.ID)
|
||||
assert.NotEmpty(t, r.LabelName)
|
||||
assert.NotEmpty(t, r.LabelSlug)
|
||||
assert.NotEmpty(t, r.CustomSlug)
|
||||
|
||||
if fix, ok := entity.LabelFixtures[r.LabelSlug]; ok {
|
||||
assert.Equal(t, fix.LabelName, r.LabelName)
|
||||
assert.Equal(t, fix.LabelSlug, r.LabelSlug)
|
||||
assert.Equal(t, fix.CustomSlug, r.CustomSlug)
|
||||
}
|
||||
}
|
||||
})
|
||||
t.Run("search for favorites", func(t *testing.T) {
|
||||
query := form.NewLabelSearch("Favorites:true Count:15")
|
||||
result, err := Labels(query)
|
||||
|
|
Loading…
Reference in a new issue