Backend: Add unit tests for internal/workers

This commit is contained in:
Theresa Gresch
2020-07-13 16:12:32 +02:00
parent 212857318b
commit 579da46f11
4 changed files with 80 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package workers
import (
"github.com/photoprism/photoprism/internal/mutex"
"testing"
"github.com/photoprism/photoprism/internal/config"
@@ -14,3 +15,29 @@ func TestNewSync(t *testing.T) {
assert.IsType(t, &Sync{}, worker)
}
func TestSync_Start(t *testing.T) {
conf := config.TestConfig()
worker := NewSync(conf)
assert.IsType(t, &Sync{}, worker)
if err := mutex.SyncWorker.Start(); err != nil {
t.Fatal(err)
}
if err := worker.Start(); err == nil {
t.Fatal("error expected")
}
mutex.SyncWorker.Stop()
if err := worker.Start(); err != nil {
t.Fatal(err)
}
if err := worker.Start(); err != nil {
t.Fatal(err)
}
}