mc_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/service/main/vipinfo/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaokeyInfo(t *testing.T) {
  10. convey.Convey("keyInfo", t, func(ctx convey.C) {
  11. var (
  12. mid = _testMid
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. p1 := keyInfo(mid)
  16. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  17. ctx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaokeyFrozen(t *testing.T) {
  23. convey.Convey("keyFrozen", t, func(ctx convey.C) {
  24. var (
  25. mid = _testMid
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. p1 := keyFrozen(mid)
  29. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  30. ctx.So(p1, convey.ShouldNotBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaopingMC(t *testing.T) {
  36. convey.Convey("pingMC", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. err := d.pingMC(c)
  42. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestDaoCacheInfo(t *testing.T) {
  49. convey.Convey("CacheInfo", t, func(ctx convey.C) {
  50. var (
  51. c = context.Background()
  52. mid = _testMid
  53. )
  54. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  55. _, err := d.CacheInfo(c, mid)
  56. ctx.Convey("Then err should be nil.v should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. })
  59. })
  60. })
  61. }
  62. func TestDaoAddCacheInfo(t *testing.T) {
  63. convey.Convey("AddCacheInfo", t, func(ctx convey.C) {
  64. var (
  65. c = context.Background()
  66. mid = _testMid
  67. v = &model.VipUserInfo{Mid: _testMid, VipType: 1, VipStatus: 1}
  68. )
  69. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  70. err := d.AddCacheInfo(c, mid, v)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoCacheInfos(t *testing.T) {
  78. convey.Convey("CacheInfos", t, func(ctx convey.C) {
  79. var (
  80. c = context.Background()
  81. mids = _testMids
  82. )
  83. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  84. for _, v := range mids {
  85. err := d.DelInfoCache(c, v)
  86. ctx.So(err, convey.ShouldBeNil)
  87. }
  88. res, err := d.CacheInfos(c, mids)
  89. fmt.Println("item", res)
  90. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  91. ctx.So(err, convey.ShouldBeNil)
  92. ctx.So(res, convey.ShouldNotBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoAddCacheInfos(t *testing.T) {
  98. convey.Convey("AddCacheInfos", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. )
  102. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  103. vs := make(map[int64]*model.VipUserInfo)
  104. vs[_testMid] = &model.VipUserInfo{Mid: _testMid, VipStatus: 1}
  105. err := d.AddCacheInfos(c, vs)
  106. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  107. ctx.So(err, convey.ShouldBeNil)
  108. })
  109. })
  110. })
  111. }
  112. func TestDaoCacheVipFrozen(t *testing.T) {
  113. convey.Convey("CacheVipFrozen", t, func(ctx convey.C) {
  114. var (
  115. c = context.Background()
  116. mid = _testMid
  117. )
  118. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  119. val, err := d.CacheVipFrozen(c, mid)
  120. fmt.Println("TestDaoCacheVipFrozen", val)
  121. ctx.Convey("Then err should be nil.val should not be nil.", func(ctx convey.C) {
  122. ctx.So(err, convey.ShouldBeNil)
  123. ctx.So(val, convey.ShouldNotBeNil)
  124. })
  125. })
  126. })
  127. }
  128. func TestDaoCacheVipFrozens(t *testing.T) {
  129. convey.Convey("CacheVipFrozens", t, func(ctx convey.C) {
  130. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  131. val, err := d.CacheVipFrozens(context.Background(), _testMids)
  132. fmt.Println("TestDaoCacheVipFrozens", val)
  133. ctx.Convey("Then err should be nil.val should not be nil.", func(ctx convey.C) {
  134. ctx.So(err, convey.ShouldBeNil)
  135. ctx.So(val, convey.ShouldNotBeNil)
  136. })
  137. })
  138. })
  139. }
  140. func TestDaoAddCacheFrozen(t *testing.T) {
  141. convey.Convey("AddCacheFrozen", t, func(ctx convey.C) {
  142. var c = context.Background()
  143. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  144. err := d.AddCacheFrozen(c, 1540883325, 1)
  145. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  146. ctx.So(err, convey.ShouldBeNil)
  147. })
  148. })
  149. })
  150. }
  151. func TestDaoDelInfoCache(t *testing.T) {
  152. convey.Convey("DelInfoCache", t, func(ctx convey.C) {
  153. var c = context.Background()
  154. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  155. err := d.DelInfoCache(c, _testMid)
  156. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  157. ctx.So(err, convey.ShouldBeNil)
  158. })
  159. })
  160. })
  161. }