initial import
This commit is contained in:
27
core/executors/lessexecutor_test.go
Normal file
27
core/executors/lessexecutor_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package executors
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"zero/core/timex"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLessExecutor_DoOrDiscard(t *testing.T) {
|
||||
executor := NewLessExecutor(time.Minute)
|
||||
assert.True(t, executor.DoOrDiscard(func() {}))
|
||||
assert.False(t, executor.DoOrDiscard(func() {}))
|
||||
executor.lastTime.Set(timex.Now() - time.Minute - time.Second*30)
|
||||
assert.True(t, executor.DoOrDiscard(func() {}))
|
||||
assert.False(t, executor.DoOrDiscard(func() {}))
|
||||
}
|
||||
|
||||
func BenchmarkLessExecutor(b *testing.B) {
|
||||
exec := NewLessExecutor(time.Millisecond)
|
||||
for i := 0; i < b.N; i++ {
|
||||
exec.DoOrDiscard(func() {
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user