41 lines
684 B
Go
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)
|
||
|
}
|
||
|
}
|