Use the new cron lib.
This commit is contained in:
@ -2,10 +2,7 @@ package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/eyebluecn/tank/code/core"
|
||||
"github.com/eyebluecn/tank/code/tool/util"
|
||||
"github.com/robfig/cron/v3"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -23,27 +20,6 @@ func TestHello(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestCron(t *testing.T) {
|
||||
|
||||
i := 0
|
||||
c := cron.New()
|
||||
spec := "*/1 * * * * ?"
|
||||
entryId, err := c.AddFunc(spec, func() {
|
||||
i++
|
||||
log.Println("cron running:", i)
|
||||
if i == 3 {
|
||||
panic("intent to panic.")
|
||||
}
|
||||
})
|
||||
fmt.Printf("entryId = %d", entryId)
|
||||
core.PanicError(err)
|
||||
|
||||
c.Start()
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
}
|
||||
|
||||
func TestDayAgo(t *testing.T) {
|
||||
|
||||
dayAgo := time.Now()
|
||||
|
Reference in New Issue
Block a user