point_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package bws
  2. import (
  3. "context"
  4. "encoding/json"
  5. "testing"
  6. "time"
  7. "go-common/app/interface/main/activity/model/bws"
  8. xtime "go-common/library/time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestDao_RawUserPoints(t *testing.T) {
  12. Convey("test cache user points", t, WithDao(func(d *Dao) {
  13. bid := int64(3)
  14. key := "9875fa517967622b"
  15. data, err := d.RawUserPoints(context.Background(), bid, key)
  16. So(err, ShouldBeNil)
  17. bs, _ := json.Marshal(data)
  18. Println(string(bs))
  19. }))
  20. }
  21. func TestDao_CacheUserPoints(t *testing.T) {
  22. Convey("test cache user points", t, WithDao(func(d *Dao) {
  23. bid := int64(3)
  24. key := "9875fa517967622b"
  25. data, err := d.CacheUserPoints(context.Background(), bid, key)
  26. So(err, ShouldBeNil)
  27. bs, _ := json.Marshal(data)
  28. Println(string(bs))
  29. }))
  30. }
  31. func TestDao_AddCacheUserPoints(t *testing.T) {
  32. Convey("add user points cache", t, WithDao(func(d *Dao) {
  33. bid := int64(3)
  34. key := "9875fa517967622b"
  35. data := []*bws.UserPoint{
  36. {ID: 1, Pid: 2, Points: 3, Ctime: xtime.Time(time.Now().Unix())},
  37. {ID: 2, Pid: 3, Points: 4, Ctime: xtime.Time(time.Now().Unix())},
  38. }
  39. err := d.AddCacheUserPoints(context.Background(), bid, data, key)
  40. So(err, ShouldBeNil)
  41. }))
  42. }