go-common/app/interface/main/activity/dao/bws/point_test.go
2019-04-22 18:49:16 +08:00

49 lines
1.2 KiB
Go

package bws
import (
"context"
"encoding/json"
"testing"
"time"
"go-common/app/interface/main/activity/model/bws"
xtime "go-common/library/time"
. "github.com/smartystreets/goconvey/convey"
)
func TestDao_RawUserPoints(t *testing.T) {
Convey("test cache user points", t, WithDao(func(d *Dao) {
bid := int64(3)
key := "9875fa517967622b"
data, err := d.RawUserPoints(context.Background(), bid, key)
So(err, ShouldBeNil)
bs, _ := json.Marshal(data)
Println(string(bs))
}))
}
func TestDao_CacheUserPoints(t *testing.T) {
Convey("test cache user points", t, WithDao(func(d *Dao) {
bid := int64(3)
key := "9875fa517967622b"
data, err := d.CacheUserPoints(context.Background(), bid, key)
So(err, ShouldBeNil)
bs, _ := json.Marshal(data)
Println(string(bs))
}))
}
func TestDao_AddCacheUserPoints(t *testing.T) {
Convey("add user points cache", t, WithDao(func(d *Dao) {
bid := int64(3)
key := "9875fa517967622b"
data := []*bws.UserPoint{
{ID: 1, Pid: 2, Points: 3, Ctime: xtime.Time(time.Now().Unix())},
{ID: 2, Pid: 3, Points: 4, Ctime: xtime.Time(time.Now().Unix())},
}
err := d.AddCacheUserPoints(context.Background(), bid, data, key)
So(err, ShouldBeNil)
}))
}