You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
384 B
Go
22 lines
384 B
Go
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))
|
|
}
|