master
兔子 1 year ago
parent dfe4801421
commit c59d801434

@ -4,7 +4,7 @@ go 1.20
require (
b612.me/stardb v1.1.4
b612.me/startimer v0.0.1
b612.me/startimer v0.0.0-20230529074834-557abef590fe
github.com/glebarez/go-sqlite v1.21.1
)

@ -1,7 +1,7 @@
b612.me/stardb v1.1.4 h1:Ic+CwGZpDKtgHTkDJ5/1kxgEEGM9Hj5xu9i0n6CbXfs=
b612.me/stardb v1.1.4/go.mod h1:qtGEu+joEQxFESl3tse5xqiD767f6sAmHD284+Xoy48=
b612.me/startimer v0.0.1 h1:7Q4hzkXZR1iFSWyEoTBjUiDx1HsROIvIel3HdfhIhxo=
b612.me/startimer v0.0.1/go.mod h1:7YlIWMVBIxLObVI0Ls+CMCCVZJ+4DdTaqF2TshthZjk=
b612.me/startimer v0.0.0-20230529074834-557abef590fe h1:Hy9hkSPiWjWvui6kiAvIShP1ZaPNT9fVJCHq5e4tZPk=
b612.me/startimer v0.0.0-20230529074834-557abef590fe/go.mod h1:7YlIWMVBIxLObVI0Ls+CMCCVZJ+4DdTaqF2TshthZjk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY=

@ -99,7 +99,7 @@ func (r *Remind) callbackFn(task *Task) {
r.callback(*task)
}
if !task.GetTimer().IsRunning() {
r.DeleteTask(task.ID)
go r.DeleteTask(task.ID)
}
}

@ -16,6 +16,30 @@ func exists(path string) bool {
}
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) {
var db stardb.StarDB

Loading…
Cancel
Save