scheduler_go/scheduler_test.go
insanity@loafle.com d34505dd62 scheduler
2017-04-29 16:17:52 +09:00

41 lines
684 B
Go

package scheduler
import (
"testing"
"log"
"time"
)
func TestScheduler(t *testing.T) {
s := Scheduler{}
s.Start()
s.NewSchedule("1111", 3, callback)
time.Sleep(time.Second * 10)
s.RemoveSchedule("1111")
time.Sleep(time.Second * 100)
}
func TestMassiveSchedule(t *testing.T) {
s := Scheduler{}
s.Start()
for i := 0; i < 9999; i++ {
s.NewSchedule(string(i), 5, test)
}
s.NewSchedule("#######################", 5, test)
time.Sleep(time.Second * 10)
s.NewSchedule("#######################", 1, test)
time.Sleep(time.Second * 100)
}
func callback(id string) {
log.Println(id)
}
func test(id string) {
if id == "#######################" {
log.Println(id)
}
}