1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 21:02:27 +08:00
Files
lancet/function/watcher_test.go
2022-01-12 09:57:10 +08:00

38 lines
591 B
Go

package function
import (
"testing"
"github.com/duke-git/lancet/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() {
var slice []int64
for i := 0; i < 10000000; i++ {
slice = append(slice, int64(i))
}
}