mc.cache_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/tv/internal/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoCacheUserInfoByMid(t *testing.T) {
  9. convey.Convey("CacheUserInfoByMid", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. id = int64(27515308)
  13. )
  14. d.AddCacheUserInfoByMid(c, id, &model.UserInfo{})
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. res, err := d.CacheUserInfoByMid(c, id)
  17. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(res, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoAddCacheUserInfoByMid(t *testing.T) {
  25. convey.Convey("AddCacheUserInfoByMid", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. id = int64(27515308)
  29. val = &model.UserInfo{}
  30. )
  31. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  32. err := d.AddCacheUserInfoByMid(c, id, val)
  33. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoDelCacheUserInfoByMid(t *testing.T) {
  40. convey.Convey("DelCacheUserInfoByMid", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. id = int64(27515308)
  44. )
  45. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  46. err := d.DelCacheUserInfoByMid(c, id)
  47. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestDaoCachePayParamByToken(t *testing.T) {
  54. convey.Convey("CachePayParamByToken", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. id = "TOKEN:34567345678"
  58. )
  59. d.AddCachePayParam(context.TODO(), id, &model.PayParam{})
  60. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  61. res, err := d.CachePayParamByToken(c, id)
  62. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.So(res, convey.ShouldNotBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoCachePayParamsByTokens(t *testing.T) {
  70. convey.Convey("CachePayParamsByTokens", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. ids = []string{"TOKEN:34567345678"}
  74. )
  75. d.AddCachePayParam(context.TODO(), ids[0], &model.PayParam{})
  76. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  77. res, err := d.CachePayParamsByTokens(c, ids)
  78. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. ctx.So(res, convey.ShouldNotBeNil)
  81. })
  82. })
  83. })
  84. }
  85. func TestDaoAddCachePayParam(t *testing.T) {
  86. convey.Convey("AddCachePayParam", t, func(ctx convey.C) {
  87. var (
  88. c = context.Background()
  89. id = "TOKEN:34567345678"
  90. val = &model.PayParam{}
  91. )
  92. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  93. err := d.AddCachePayParam(c, id, val)
  94. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. })
  97. })
  98. })
  99. }
  100. func TestDaoUpdateCachePayParam(t *testing.T) {
  101. convey.Convey("UpdateCachePayParam", t, func(ctx convey.C) {
  102. var (
  103. c = context.Background()
  104. id = "TOKEN:34567345678"
  105. val = &model.PayParam{}
  106. )
  107. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  108. err := d.UpdateCachePayParam(c, id, val)
  109. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldBeNil)
  111. })
  112. })
  113. })
  114. }