mc_test.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/passport-game/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyInfoPB(t *testing.T) {
  9. var (
  10. mid = int64(12)
  11. )
  12. convey.Convey("keyInfoPB", t, func(ctx convey.C) {
  13. p1 := keyInfoPB(mid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaokeyTokenPB(t *testing.T) {
  20. var (
  21. accessToken = "123"
  22. )
  23. convey.Convey("keyTokenPB", t, func(ctx convey.C) {
  24. p1 := keyTokenPB(accessToken)
  25. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  26. ctx.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestDaokeyOriginMissMatchFlag(t *testing.T) {
  31. var (
  32. identify = "123"
  33. )
  34. convey.Convey("keyOriginMissMatchFlag", t, func(ctx convey.C) {
  35. p1 := keyOriginMissMatchFlag(identify)
  36. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  37. ctx.So(p1, convey.ShouldNotBeNil)
  38. })
  39. })
  40. }
  41. func TestDaopingMC(t *testing.T) {
  42. var (
  43. c = context.TODO()
  44. )
  45. convey.Convey("pingMC", t, func(ctx convey.C) {
  46. err := d.pingMC(c)
  47. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  48. ctx.So(err, convey.ShouldBeNil)
  49. })
  50. })
  51. }
  52. func TestDaoSetInfoCache(t *testing.T) {
  53. var (
  54. c = context.TODO()
  55. info = &model.Info{}
  56. )
  57. convey.Convey("SetInfoCache", t, func(ctx convey.C) {
  58. err := d.SetInfoCache(c, info)
  59. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  60. ctx.So(err, convey.ShouldBeNil)
  61. })
  62. })
  63. }
  64. func TestDaoInfoCache(t *testing.T) {
  65. var (
  66. c = context.TODO()
  67. mid = int64(0)
  68. )
  69. convey.Convey("InfoCache", t, func(ctx convey.C) {
  70. info, err := d.InfoCache(c, mid)
  71. ctx.Convey("Then err should be nil.info should not be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. ctx.So(info, convey.ShouldNotBeNil)
  74. })
  75. })
  76. }
  77. func TestDaoTokenCache(t *testing.T) {
  78. var (
  79. c = context.TODO()
  80. accessToken = "123456"
  81. token = &model.Perm{
  82. Mid: -1,
  83. AccessToken: accessToken,
  84. }
  85. )
  86. convey.Convey("TestDaoTokenCache", t, func(ctx convey.C) {
  87. err := d.SetTokenCache(c, token)
  88. ctx.Convey("SetTokenCache", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. })
  91. token, err := d.TokenCache(c, accessToken)
  92. ctx.Convey("TokenCache", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(token, convey.ShouldNotBeNil)
  95. })
  96. err = d.DelTokenCache(c, accessToken)
  97. ctx.Convey("DelTokenCache", func(ctx convey.C) {
  98. ctx.So(err, convey.ShouldBeNil)
  99. })
  100. token, err = d.TokenCache(c, accessToken)
  101. ctx.Convey("DeletedTokenCache", func(ctx convey.C) {
  102. ctx.So(err, convey.ShouldBeNil)
  103. ctx.So(token, convey.ShouldBeNil)
  104. })
  105. })
  106. }
  107. func TestDaoSetOriginMissMatchFlagCache(t *testing.T) {
  108. var (
  109. c = context.TODO()
  110. identify = "123456"
  111. flag = []byte("")
  112. )
  113. convey.Convey("SetOriginMissMatchFlagCache", t, func(ctx convey.C) {
  114. err := d.SetOriginMissMatchFlagCache(c, identify, flag)
  115. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  116. ctx.So(err, convey.ShouldBeNil)
  117. })
  118. })
  119. }
  120. func TestDaoOriginMissMatchFlagCache(t *testing.T) {
  121. var (
  122. c = context.TODO()
  123. identify = "123456"
  124. )
  125. convey.Convey("OriginMissMatchFlagCache", t, func(ctx convey.C) {
  126. res, err := d.OriginMissMatchFlagCache(c, identify)
  127. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  128. ctx.So(err, convey.ShouldBeNil)
  129. ctx.So(res, convey.ShouldNotBeNil)
  130. })
  131. })
  132. }
  133. func TestDaoDelOriginMissMatchFlagCache(t *testing.T) {
  134. var (
  135. c = context.TODO()
  136. identify = "123456"
  137. )
  138. convey.Convey("DelOriginMissMatchFlagCache", t, func(ctx convey.C) {
  139. err := d.DelOriginMissMatchFlagCache(c, identify)
  140. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  141. ctx.So(err, convey.ShouldBeNil)
  142. })
  143. })
  144. }
  145. func TestDaoOriginTokenCache(t *testing.T) {
  146. var (
  147. c = context.TODO()
  148. accessToken = "123456"
  149. token = &model.Token{
  150. Mid: -1,
  151. AccessToken: accessToken,
  152. }
  153. )
  154. convey.Convey("TestDaoOriginTokenCache", t, func(ctx convey.C) {
  155. err := d.SetOriginTokenCache(c, token)
  156. ctx.Convey("SetOriginTokenCache", func(ctx convey.C) {
  157. ctx.So(err, convey.ShouldBeNil)
  158. })
  159. token, err := d.OriginTokenCache(c, accessToken)
  160. ctx.Convey("OriginTokenCache", func(ctx convey.C) {
  161. ctx.So(err, convey.ShouldBeNil)
  162. ctx.So(token, convey.ShouldNotBeNil)
  163. })
  164. err = d.DelOriginTokenCache(c, accessToken)
  165. ctx.Convey("DelOriginTokenCache", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. })
  168. token, err = d.OriginTokenCache(c, accessToken)
  169. ctx.Convey("DeletedOriginTokenCache", func(ctx convey.C) {
  170. ctx.So(err, convey.ShouldBeNil)
  171. ctx.So(token, convey.ShouldBeNil)
  172. })
  173. })
  174. }