|
|
@ -16,6 +16,30 @@ func exists(path string) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err == nil
|
|
|
|
return err == nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStarDB(t *testing.T) {
|
|
|
|
|
|
|
|
var db stardb.StarDB
|
|
|
|
|
|
|
|
err := db.Open("sqlite", "./db.sqlite")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var r *Remind
|
|
|
|
|
|
|
|
r, err = NewRemind(&db, func(task Task) {
|
|
|
|
|
|
|
|
fmt.Println("hello world!", time.Now(), task.ID, task.Key, task.TmrInfo, task.Msg, task.Origin)
|
|
|
|
|
|
|
|
fmt.Println(task.GetTimer().NextTimer(), task.GetTimer().IsRunning())
|
|
|
|
|
|
|
|
fmt.Println(r.ListTasks())
|
|
|
|
|
|
|
|
fmt.Println("ok")
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
|
|
|
fmt.Println(task.GetTimer().NextTimer())
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
tk, err := r.AddTask("每天下午3点52分20秒提醒我吃饭", "00", []byte{})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(tk.GetTimer().NextTimer())
|
|
|
|
|
|
|
|
fmt.Println(r.ListTasks())
|
|
|
|
|
|
|
|
fmt.Println("hello")
|
|
|
|
|
|
|
|
time.Sleep(time.Second * 120)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestOtherDb(t *testing.T) {
|
|
|
|
func TestOtherDb(t *testing.T) {
|
|
|
|
var db stardb.StarDB
|
|
|
|
var db stardb.StarDB
|
|
|
|