2020-05-01 09:57:38 +02:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2021-01-08 12:20:41 +01:00
|
|
|
gc "github.com/patrickmn/go-cache"
|
|
|
|
|
2020-05-01 09:57:38 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/classify"
|
|
|
|
"github.com/photoprism/photoprism/internal/nsfw"
|
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
|
|
"github.com/photoprism/photoprism/internal/query"
|
|
|
|
"github.com/photoprism/photoprism/internal/session"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
c := config.TestConfig()
|
|
|
|
|
|
|
|
SetConfig(c)
|
|
|
|
|
|
|
|
code := m.Run()
|
|
|
|
|
2020-05-08 18:35:19 +02:00
|
|
|
_ = c.CloseDb()
|
|
|
|
|
2020-05-01 09:57:38 +02:00
|
|
|
os.Exit(code)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig(t *testing.T) {
|
|
|
|
assert.Equal(t, conf, Config())
|
|
|
|
}
|
|
|
|
|
2021-01-08 13:29:01 +01:00
|
|
|
func TestFolderCache(t *testing.T) {
|
|
|
|
assert.IsType(t, &gc.Cache{}, FolderCache())
|
2021-01-08 12:20:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCoverCache(t *testing.T) {
|
|
|
|
assert.IsType(t, &gc.Cache{}, CoverCache())
|
|
|
|
}
|
|
|
|
|
2021-01-08 12:52:26 +01:00
|
|
|
func TestThumbCache(t *testing.T) {
|
|
|
|
assert.IsType(t, &gc.Cache{}, ThumbCache())
|
|
|
|
}
|
|
|
|
|
2020-05-01 09:57:38 +02:00
|
|
|
func TestClassify(t *testing.T) {
|
|
|
|
assert.IsType(t, &classify.TensorFlow{}, Classify())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConvert(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Convert{}, Convert())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestImport(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Import{}, Import())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIndex(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Index{}, Index())
|
|
|
|
}
|
|
|
|
|
2020-05-29 18:04:30 +02:00
|
|
|
func TestMoments(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Moments{}, Moments())
|
|
|
|
}
|
|
|
|
|
2020-05-07 19:42:04 +02:00
|
|
|
func TestPurge(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Purge{}, Purge())
|
|
|
|
}
|
|
|
|
|
2021-01-24 17:46:18 +01:00
|
|
|
func TestCleanUp(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.CleanUp{}, CleanUp())
|
|
|
|
}
|
|
|
|
|
2020-05-01 09:57:38 +02:00
|
|
|
func TestNsfwDetector(t *testing.T) {
|
|
|
|
assert.IsType(t, &nsfw.Detector{}, NsfwDetector())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQuery(t *testing.T) {
|
|
|
|
assert.IsType(t, &query.Query{}, Query())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestResample(t *testing.T) {
|
|
|
|
assert.IsType(t, &photoprism.Resample{}, Resample())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSession(t *testing.T) {
|
|
|
|
assert.IsType(t, &session.Session{}, Session())
|
|
|
|
}
|