achievement_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_CacheAchieveCounts(t *testing.T) {
  12. Convey("test cache achieve count", t, WithDao(func(d *Dao) {
  13. bid := int64(3)
  14. day := "20180712"
  15. data, err := d.CacheAchieveCounts(context.Background(), bid, day)
  16. So(err, ShouldBeNil)
  17. bs, _ := json.Marshal(data)
  18. Printf("%v", string(bs))
  19. }))
  20. }
  21. func TestDao_AddCacheAchieveCounts(t *testing.T) {
  22. Convey("test add cache achieve count", t, WithDao(func(d *Dao) {
  23. bid := int64(3)
  24. day := "20180712"
  25. list := []*bws.CountAchieves{
  26. {Aid: 111, Count: 222},
  27. {Aid: 222, Count: 333},
  28. }
  29. err := d.AddCacheAchieveCounts(context.Background(), bid, list, day)
  30. So(err, ShouldBeNil)
  31. }))
  32. }
  33. func TestDao_AddCacheUserAchieves(t *testing.T) {
  34. Convey("test add cache", t, WithDao(func(d *Dao) {
  35. bid := int64(3)
  36. list := []*bws.UserAchieve{
  37. {ID: 2, Aid: 3, Award: 0, Ctime: xtime.Time(time.Now().Unix())},
  38. {ID: 3, Aid: 4, Award: 0, Ctime: xtime.Time(time.Now().Unix())},
  39. }
  40. key := "9abf1997abe851e6"
  41. err := d.AddCacheUserAchieves(context.Background(), bid, list, key)
  42. So(err, ShouldBeNil)
  43. }))
  44. }
  45. func TestDao_CacheUserAchieves(t *testing.T) {
  46. Convey("test cache user achieves", t, WithDao(func(d *Dao) {
  47. bid := int64(3)
  48. key := "9abf1997abe851e6"
  49. data, err := d.CacheUserAchieves(context.Background(), bid, key)
  50. So(err, ShouldBeNil)
  51. bs, _ := json.Marshal(data)
  52. Printf("%v", string(bs))
  53. }))
  54. }
  55. func TestDao_AddLotteryMidCache(t *testing.T) {
  56. Convey("test add lottery mid cache", t, WithDao(func(d *Dao) {
  57. aid := int64(3)
  58. mid := int64(908085)
  59. for i := 0; i < 10; i++ {
  60. err := d.AddLotteryMidCache(context.Background(), aid, mid+int64(i))
  61. So(err, ShouldBeNil)
  62. }
  63. }))
  64. }
  65. func TestDao_LotteryMidCache(t *testing.T) {
  66. Convey("test get lottery mid cache", t, WithDao(func(d *Dao) {
  67. aid := int64(3)
  68. mid, err := d.CacheLotteryMid(context.Background(), aid, "")
  69. So(err, ShouldBeNil)
  70. Println(mid)
  71. }))
  72. }
  73. func TestDao_RawAchieveCounts(t *testing.T) {
  74. Convey("test achieve count", t, WithDao(func(d *Dao) {
  75. bid := int64(1)
  76. day := "20180712"
  77. data, err := d.RawAchieveCounts(context.Background(), bid, day)
  78. So(err, ShouldBeNil)
  79. Printf("%+v", data)
  80. }))
  81. }
  82. func TestDao_RawAchievements(t *testing.T) {
  83. Convey("test raw achievements", t, WithDao(func(d *Dao) {
  84. bid := int64(1)
  85. data, err := d.RawAchievements(context.Background(), bid)
  86. So(err, ShouldBeNil)
  87. Printf("%+v", data)
  88. }))
  89. }