WebUI/src/util/counter_test.go
Theta-Dev 60034b4815
All checks were successful
continuous-integration/drone/push Build is passing
add server base
2022-02-01 23:08:45 +01:00

30 lines
381 B
Go

package util
import (
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCounter(t *testing.T) {
counter := Counter{}
var wg sync.WaitGroup
incrementer := func() {
for i := 0; i < 50; i++ {
counter.Increment()
}
wg.Done()
}
for i := 0; i < 100; i++ {
wg.Add(1)
go incrementer()
}
wg.Wait()
assert.EqualValues(t, 5000, counter.Get())
}