initial import
This commit is contained in:
21
core/executors/delayexecutor_test.go
Normal file
21
core/executors/delayexecutor_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package executors
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDelayExecutor(t *testing.T) {
|
||||
var count int32
|
||||
ex := NewDelayExecutor(func() {
|
||||
atomic.AddInt32(&count, 1)
|
||||
}, time.Millisecond*10)
|
||||
for i := 0; i < 100; i++ {
|
||||
ex.Trigger()
|
||||
}
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
assert.Equal(t, int32(1), atomic.LoadInt32(&count))
|
||||
}
|
||||
Reference in New Issue
Block a user