genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/lib/worker/worker_test.go

25 lines
400 B
Go
Raw Normal View History

package worker
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWorker(t *testing.T) {
assert := assert.New(t)
runtime := 0
w := NewWorker(time.Duration(5)*time.Millisecond, func() {
runtime = runtime + 1
})
go w.Start()
time.Sleep(time.Duration(18) * time.Millisecond)
w.Close()
assert.Equal(3, runtime)
time.Sleep(time.Duration(8) * time.Millisecond)
}