photoprism/internal/workers/sync_download_test.go
Michael Mayer 161b36f8a4 Refactor config and worker tests for better performance
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-07-13 20:25:47 +02:00

49 lines
1 KiB
Go

package workers
import (
"github.com/photoprism/photoprism/internal/entity"
"strings"
"testing"
"github.com/photoprism/photoprism/internal/config"
"github.com/stretchr/testify/assert"
)
func TestSync_download(t *testing.T) {
conf := config.TestConfig()
t.Logf("database-dsn: %s", conf.DatabaseDsn())
worker := NewSync(conf)
assert.IsType(t, &Sync{}, worker)
account := entity.AccountFixtureWebdavDummy
if _, err := worker.download(account); err != nil {
t.Fatal(err)
}
}
func TestSync_downloadPath(t *testing.T) {
conf := config.TestConfig()
worker := NewSync(conf)
assert.IsType(t, &Sync{}, worker)
assert.True(t, strings.HasSuffix(worker.downloadPath(), "testdata/temp/sync"))
}
func TestSync_relatedDownloads(t *testing.T) {
conf := config.TestConfig()
worker := NewSync(conf)
account := entity.AccountFixtureWebdavDummy
assert.IsType(t, &Sync{}, worker)
if result, err := worker.relatedDownloads(account); err != nil {
t.Fatal(err)
} else {
assert.IsType(t, Downloads{}, result)
}
}