gh-ost/vendor/github.com/ngaut/systimemon/systime_mon_test.go
2017-02-12 13:17:56 +02:00

29 lines
411 B
Go

package systimemon
import (
"testing"
"time"
)
func TestSystimeMonitor(t *testing.T) {
jumpForward := false
trigged := false
go StartMonitor(
func() time.Time {
if !trigged {
trigged = true
return time.Now()
}
return time.Now().Add(-2 * time.Second)
}, func() {
jumpForward = true
})
time.Sleep(1 * time.Second)
if !jumpForward {
t.Error("should detect time error")
}
}