1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00
Files
lancet/function/watcher_test.go
2022-10-15 15:03:24 +08:00

39 lines
612 B
Go

package function
import (
"testing"
"github.com/duke-git/lancet/v2/internal"
)
func TestWatcher(t *testing.T) {
assert := internal.NewAssert(t, "TestWatcher")
w := &Watcher{}
w.Start()
longRunningTask()
assert.Equal(true, w.excuting)
w.Stop()
eapsedTime := w.GetElapsedTime().Milliseconds()
t.Log("Elapsed Time (milsecond)", eapsedTime)
assert.Equal(false, w.excuting)
w.Reset()
assert.Equal(int64(0), w.startTime)
assert.Equal(int64(0), w.stopTime)
}
func longRunningTask() []int64 {
var data []int64
for i := 0; i < 10000000; i++ {
data = append(data, int64(i))
}
return data
}