From c59d801434844ccc20b3cc15e86cee63f550327b Mon Sep 17 00:00:00 2001 From: starainrt Date: Mon, 29 May 2023 15:52:53 +0800 Subject: [PATCH] bug fix --- go.mod | 2 +- go.sum | 4 ++-- remind/remind.go | 2 +- remind/reminde_test.go | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fcdee4a..bbccff1 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 00974d7..2d4a51e 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/remind/remind.go b/remind/remind.go index ef9a86a..4c7a8ad 100644 --- a/remind/remind.go +++ b/remind/remind.go @@ -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) } } diff --git a/remind/reminde_test.go b/remind/reminde_test.go index 38a6681..118430a 100644 --- a/remind/reminde_test.go +++ b/remind/reminde_test.go @@ -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