2020-07-13 16:44:17 +02:00
|
|
|
package workers
|
|
|
|
|
|
|
|
import (
|
2020-07-13 18:54:32 +02:00
|
|
|
"strings"
|
2020-07-13 16:44:17 +02:00
|
|
|
"testing"
|
|
|
|
|
2020-11-21 18:08:41 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/entity"
|
|
|
|
|
2020-07-13 16:44:17 +02:00
|
|
|
"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)
|
2022-10-15 21:54:11 +02:00
|
|
|
account := entity.ServiceFixtureWebdavDummy
|
2020-07-13 16:44:17 +02:00
|
|
|
|
2020-07-13 20:25:47 +02:00
|
|
|
if _, err := worker.download(account); err != nil {
|
2020-07-13 16:44:17 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSync_downloadPath(t *testing.T) {
|
|
|
|
conf := config.TestConfig()
|
|
|
|
|
|
|
|
worker := NewSync(conf)
|
|
|
|
|
|
|
|
assert.IsType(t, &Sync{}, worker)
|
2020-07-13 18:54:32 +02:00
|
|
|
assert.True(t, strings.HasSuffix(worker.downloadPath(), "testdata/temp/sync"))
|
2020-07-13 16:44:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSync_relatedDownloads(t *testing.T) {
|
|
|
|
conf := config.TestConfig()
|
|
|
|
|
|
|
|
worker := NewSync(conf)
|
2022-10-15 21:54:11 +02:00
|
|
|
account := entity.ServiceFixtureWebdavDummy
|
2020-07-13 16:44:17 +02:00
|
|
|
|
|
|
|
assert.IsType(t, &Sync{}, worker)
|
2020-07-13 20:25:47 +02:00
|
|
|
|
|
|
|
if result, err := worker.relatedDownloads(account); err != nil {
|
2020-07-13 16:44:17 +02:00
|
|
|
t.Fatal(err)
|
2020-07-13 20:25:47 +02:00
|
|
|
} else {
|
|
|
|
assert.IsType(t, Downloads{}, result)
|
2020-07-13 16:44:17 +02:00
|
|
|
}
|
|
|
|
}
|