1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/semerrgroup/sem_test.go
Carlos Alexandro Becker 8e62dddd29
test: improved tests
2018-07-09 22:04:25 -07:00

27 lines
405 B
Go

package semerrgroup
import (
"sync"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestSemaphore(t *testing.T) {
var g = New(4)
var lock sync.Mutex
var counter int
for i := 0; i < 10; i++ {
g.Go(func() error {
time.Sleep(10 * time.Millisecond)
lock.Lock()
counter++
lock.Unlock()
return nil
})
}
require.NoError(t, g.Wait())
require.Equal(t, counter, 10)
}