memcache_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package dao
  2. import (
  3. "testing"
  4. "context"
  5. "go-common/app/job/main/vip/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDao_DelVipInfoCache(t *testing.T) {
  9. Convey("should return true where err != nil and res not empty", t, func() {
  10. err := d.DelVipInfoCache(context.TODO(), 1234)
  11. So(err, ShouldBeNil)
  12. })
  13. }
  14. func TestDao_SetVipInfoCache(t *testing.T) {
  15. Convey("set vip info cache", t, func() {
  16. err := d.SetVipInfoCache(context.TODO(), 1234, &model.VipInfo{Mid: 1234, VipType: model.Vip, VipStatus: model.VipStatusNotOverTime})
  17. So(err, ShouldBeNil)
  18. })
  19. }
  20. func TestDao_AddPayOrderLog(t *testing.T) {
  21. Convey("add pay order log", t, func() {
  22. _, err := d.AddPayOrderLog(context.TODO(), &model.VipPayOrderLog{Mid: 1234, Status: 1, OrderNo: "12891723894189"})
  23. So(err, ShouldBeNil)
  24. })
  25. }
  26. func TestDao_GetVipMadelCache(t *testing.T) {
  27. Convey("get vip madel cache ", t, func() {
  28. val, err := d.GetVipMadelCache(context.TODO(), 2089801)
  29. t.Logf("val %v \n", val)
  30. So(err, ShouldBeNil)
  31. })
  32. }
  33. func TestDao_SetVipMadelCache(t *testing.T) {
  34. Convey("set vip madel", t, func() {
  35. err := d.SetVipMadelCache(context.TODO(), 2089801, 1)
  36. So(err, ShouldBeNil)
  37. })
  38. }
  39. func TestDao_SetVipFrozen(t *testing.T) {
  40. Convey("set vip frozen", t, func() {
  41. err := d.SetVipFrozen(context.TODO(), 2089809)
  42. So(err, ShouldBeNil)
  43. })
  44. }
  45. func TestDao_GetVipBuyCache(t *testing.T) {
  46. var val int64 = 1
  47. Convey("SetVipBuyCache", t, func() {
  48. err := d.SetVipBuyCache(context.TODO(), 2089809, val)
  49. So(err, ShouldBeNil)
  50. })
  51. Convey("GetVipBuyCache", t, func() {
  52. res, err := d.GetVipBuyCache(context.TODO(), 2089809)
  53. So(err, ShouldBeNil)
  54. So(val, ShouldEqual, res)
  55. })
  56. }
  57. func TestDao_AddTransferLock(t *testing.T) {
  58. Convey("AddTransferLock", t, func() {
  59. err := d.delCache(context.TODO(), "2089809")
  60. So(err, ShouldBeNil)
  61. bool := d.AddTransferLock(context.TODO(), "2089809")
  62. So(bool, ShouldBeTrue)
  63. })
  64. }