Backend: Add unit tests for internal/mutex

This commit is contained in:
Theresa Gresch
2020-07-08 13:18:19 +02:00
parent b3487fa3b3
commit a0d858e56f
2 changed files with 29 additions and 0 deletions

View File

@@ -21,3 +21,21 @@ func TestBusy_Busy(t *testing.T) {
assert.False(t, b.Canceled())
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())
})
}

View File

@@ -0,0 +1,11 @@
package mutex
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWorkersBusy(t *testing.T) {
assert.False(t, WorkersBusy())
}