update
parent
66828b2c23
commit
b342ed0dbc
@ -1,4 +1,27 @@
|
||||
b612.me/stardb v1.1.3 h1:cx16v64FmfCh+cCF6GDDiVUF+ZISpBxBH3t2GkBkeJY=
|
||||
b612.me/stardb v1.1.3/go.mod h1:qtGEu+joEQxFESl3tse5xqiD767f6sAmHD284+Xoy48=
|
||||
b612.me/startimer v0.0.0-20230501080256-b0fd8947f0dc h1:WO8jZiLVssi3myTWX5Oo/+/i9vk+Alo4ymJhHi4TXp0=
|
||||
b612.me/startimer v0.0.0-20230501080256-b0fd8947f0dc/go.mod h1:8fw+OU7SnxzuLkNCYSbRKmvs4WtHs6SbCHuTf5F6s+U=
|
||||
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=
|
||||
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=
|
||||
github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E=
|
||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY=
|
||||
modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw=
|
||||
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
|
||||
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
|
||||
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
||||
modernc.org/sqlite v1.21.1 h1:GyDFqNnESLOhwwDRaHGdp2jKLDzpyT/rNLglX3ZkMSU=
|
||||
modernc.org/sqlite v1.21.1/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI=
|
||||
|
@ -0,0 +1,58 @@
|
||||
package remind
|
||||
|
||||
import (
|
||||
"b612.me/stardb"
|
||||
"fmt"
|
||||
_ "github.com/glebarez/go-sqlite"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func exists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func TestRemind(t *testing.T) {
|
||||
var db stardb.StarDB
|
||||
err := db.Open("sqlite", "./remind.db")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sign := make(chan int)
|
||||
r, err := NewRemind(&db, func(task Task) {
|
||||
fmt.Println("hello world!", time.Now(), task.ID, task.Key, task.TmrInfo, task.Msg, task.Origin)
|
||||
sign <- 1
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println("length of remind", len(r.ListTasks()))
|
||||
if len(r.ListTasks()) < 2 {
|
||||
tk, err := r.AddTask("每8秒提醒我吃饭", "干饭", []byte{1, 2, 3})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tmr := tk.GetTimer()
|
||||
fmt.Println(tmr.NextTimer())
|
||||
}
|
||||
i := 0
|
||||
for {
|
||||
select {
|
||||
case <-sign:
|
||||
i++
|
||||
break
|
||||
case <-time.After(time.Second * 15):
|
||||
t.FailNow()
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
fmt.Println(len(r.ListTasks()))
|
||||
if i == 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue