mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Backend: Add unit tests for internal/mutex
This commit is contained in:
@@ -21,3 +21,21 @@ func TestBusy_Busy(t *testing.T) {
|
|||||||
assert.False(t, b.Canceled())
|
assert.False(t, b.Canceled())
|
||||||
assert.False(t, b.Busy())
|
assert.False(t, b.Busy())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBusy_Start(t *testing.T) {
|
||||||
|
t.Run("cancelled true", func(t *testing.T) {
|
||||||
|
b := Busy{canceled: true}
|
||||||
|
|
||||||
|
assert.Error(t, b.Start(), "still running")
|
||||||
|
})
|
||||||
|
t.Run("busy true", func(t *testing.T) {
|
||||||
|
b := Busy{busy: true}
|
||||||
|
|
||||||
|
assert.Error(t, b.Start(), "already running")
|
||||||
|
})
|
||||||
|
t.Run("success", func(t *testing.T) {
|
||||||
|
b := Busy{}
|
||||||
|
|
||||||
|
assert.Nil(t, b.Start())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
11
internal/mutex/mutex_test.go
Normal file
11
internal/mutex/mutex_test.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package mutex
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestWorkersBusy(t *testing.T) {
|
||||||
|
assert.False(t, WorkersBusy())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user