1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-14 18:40:40 +00:00

add api for testing

This commit is contained in:
Anker Jam
2020-10-05 10:33:23 +08:00
parent 70cca5e298
commit b838683731
4 changed files with 43 additions and 12 deletions

View File

@ -212,6 +212,11 @@ func DeleteTask(taskname string) {
task.DeleteTask(taskname)
}
// ClearTask clear all tasks
func ClearTask() {
task.ClearTask()
}
// MapSorter sort map for tasker
type MapSorter task.MapSorter

View File

@ -22,6 +22,8 @@ import (
)
func TestParse(t *testing.T) {
defer ClearTask()
tk := NewTask("taska", "0/30 * * * * *", func() error { fmt.Println("hello world"); return nil })
err := tk.Run()
if err != nil {
@ -34,6 +36,8 @@ func TestParse(t *testing.T) {
}
func TestSpec(t *testing.T) {
defer ClearTask()
wg := &sync.WaitGroup{}
wg.Add(2)
tk1 := NewTask("tk1", "0 12 * * * *", func() error { fmt.Println("tk1"); return nil })