chore: remove directive for tests (#3257)

This commit is contained in:
Kevin Wan
2023-05-18 21:34:33 +08:00
committed by GitHub
parent f7228e9af1
commit 90839965fa
3 changed files with 35 additions and 14 deletions

View File

@@ -5,7 +5,9 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/collection"
"github.com/zeromicro/go-zero/core/proc"
"github.com/zeromicro/go-zero/core/timex"
)
func TestNextDelay(t *testing.T) {
@@ -49,6 +51,18 @@ func TestNextDelay(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
old := timingWheel.Load()
ticker := timex.NewFakeTicker()
tw, err := collection.NewTimingWheelWithTicker(
time.Millisecond, timingWheelSlots, func(key, value any) {
clean(key, value)
}, ticker)
timingWheel.Store(tw)
assert.NoError(t, err)
t.Cleanup(func() {
timingWheel.Store(old)
})
next, ok := nextDelay(test.input)
assert.Equal(t, test.ok, ok)
assert.Equal(t, test.output, next)