2020-05-13 10:16:12 +02:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-05-14 15:05:10 +02:00
|
|
|
"time"
|
2020-11-21 18:08:41 +01:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2020-05-13 10:16:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestFileShares(t *testing.T) {
|
|
|
|
t.Run("search for id and status", func(t *testing.T) {
|
2020-05-14 15:43:39 +02:00
|
|
|
r, err := FileShares(uint(1000001), "new")
|
2020-05-13 10:16:12 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(r))
|
|
|
|
for _, r := range r {
|
|
|
|
assert.IsType(t, entity.FileShare{}, r)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestExpiredFileShares(t *testing.T) {
|
2020-05-14 15:05:10 +02:00
|
|
|
t.Run("expired file share exists", func(t *testing.T) {
|
|
|
|
time.Sleep(2 * time.Second)
|
2022-10-15 21:54:11 +02:00
|
|
|
r, err := ExpiredFileShares(entity.ServiceFixtureWebdavDummy)
|
2020-05-13 10:16:12 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, len(r))
|
|
|
|
for _, r := range r {
|
|
|
|
assert.IsType(t, entity.FileShare{}, r)
|
|
|
|
}
|
2020-05-14 15:05:10 +02:00
|
|
|
})
|
2020-05-13 10:16:12 +02:00
|
|
|
t.Run("expired file does not exists", func(t *testing.T) {
|
2022-10-15 21:54:11 +02:00
|
|
|
r, err := ExpiredFileShares(entity.ServiceFixtureWebdavDummy2)
|
2020-05-13 10:16:12 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Empty(t, r)
|
|
|
|
})
|
|
|
|
}
|