2020-05-26 15:15:14 +02:00
|
|
|
package workers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
|
|
|
"github.com/photoprism/photoprism/internal/mutex"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2020-05-26 19:27:29 +02:00
|
|
|
func TestPrism_Start(t *testing.T) {
|
2020-05-26 15:15:14 +02:00
|
|
|
conf := config.TestConfig()
|
|
|
|
|
2020-05-30 14:52:47 +02:00
|
|
|
t.Logf("database-dsn: %s", conf.DatabaseDsn())
|
|
|
|
|
2020-05-26 19:27:29 +02:00
|
|
|
worker := NewPrism(conf)
|
2020-05-26 15:15:14 +02:00
|
|
|
|
2020-05-26 19:27:29 +02:00
|
|
|
assert.IsType(t, &Prism{}, worker)
|
2020-05-26 15:15:14 +02:00
|
|
|
|
2020-05-26 19:27:29 +02:00
|
|
|
if err := mutex.PrismWorker.Start(); err != nil {
|
2020-05-26 15:15:14 +02:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := worker.Start(); err == nil {
|
|
|
|
t.Fatal("error expected")
|
|
|
|
}
|
|
|
|
|
2020-05-26 19:27:29 +02:00
|
|
|
mutex.PrismWorker.Stop()
|
|
|
|
|
|
|
|
if err := worker.Start(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2020-05-26 15:15:14 +02:00
|
|
|
|
|
|
|
if err := worker.Start(); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|