2020-05-26 15:15:14 +02:00
|
|
|
package workers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-21 18:08:41 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/mutex"
|
|
|
|
|
2020-05-26 15:15:14 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewShare(t *testing.T) {
|
|
|
|
conf := config.TestConfig()
|
|
|
|
|
|
|
|
worker := NewShare(conf)
|
|
|
|
|
|
|
|
assert.IsType(t, &Share{}, worker)
|
|
|
|
}
|
2020-07-13 16:12:32 +02:00
|
|
|
|
|
|
|
func TestShare_Start(t *testing.T) {
|
|
|
|
conf := config.TestConfig()
|
|
|
|
|
|
|
|
worker := NewShare(conf)
|
|
|
|
|
|
|
|
assert.IsType(t, &Share{}, worker)
|
|
|
|
|
|
|
|
if err := mutex.ShareWorker.Start(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := worker.Start(); err == nil {
|
|
|
|
t.Fatal("error expected")
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex.ShareWorker.Stop()
|
|
|
|
|
|
|
|
if err := worker.Start(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|