mc_test.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/passport-auth/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaockKey(t *testing.T) {
  9. var (
  10. session = "9f1c9145,1536117849,c9fb62a9"
  11. )
  12. convey.Convey("ckKey", t, func(ctx convey.C) {
  13. p1 := ckKey(session)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoakKey(t *testing.T) {
  20. var (
  21. token = "b8b544c602557c27d454911d7ecc006c"
  22. )
  23. convey.Convey("akKey", t, func(ctx convey.C) {
  24. p1 := akKey(token)
  25. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  26. ctx.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestDaorkKey(t *testing.T) {
  31. var (
  32. refresh = "5f263d1297aa40ea0252c0963e29c6eb"
  33. )
  34. convey.Convey("rkKey", t, func(ctx convey.C) {
  35. p1 := rkKey(refresh)
  36. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  37. ctx.So(p1, convey.ShouldNotBeNil)
  38. })
  39. })
  40. }
  41. func TestDaoSetCookieCache(t *testing.T) {
  42. var (
  43. c = context.TODO()
  44. session = "9f1c9145,1536117849,c9fb62a9"
  45. res = &model.Cookie{}
  46. )
  47. convey.Convey("SetCookieCache", t, func(ctx convey.C) {
  48. err := d.SetCookieCache(c, session, res)
  49. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. })
  52. })
  53. }
  54. func TestDaoCookieCache(t *testing.T) {
  55. var (
  56. c = context.TODO()
  57. session = "9f1c9145,1536117849,c9fb62a9"
  58. )
  59. convey.Convey("CookieCache", t, func(ctx convey.C) {
  60. res, err := d.CookieCache(c, session)
  61. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. ctx.So(res, convey.ShouldNotBeNil)
  64. })
  65. })
  66. }
  67. func TestDaoDelCookieCache(t *testing.T) {
  68. var (
  69. c = context.TODO()
  70. session = "9f1c9145,1536117849,c9fb62a9"
  71. )
  72. convey.Convey("DelCookieCache", t, func(ctx convey.C) {
  73. err := d.DelCookieCache(c, session)
  74. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. })
  77. })
  78. }
  79. func TestDaoSetTokenCache(t *testing.T) {
  80. var (
  81. c = context.TODO()
  82. k = "5f263d1297aa40ea0252c0963e29c6eb"
  83. res = &model.Token{}
  84. )
  85. convey.Convey("SetTokenCache", t, func(ctx convey.C) {
  86. err := d.SetTokenCache(c, k, res)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. }
  92. func TestDaoTokenCache(t *testing.T) {
  93. var (
  94. c = context.TODO()
  95. sd = "5f263d1297aa40ea0252c0963e29c6eb"
  96. )
  97. convey.Convey("TokenCache", t, func(ctx convey.C) {
  98. res, err := d.TokenCache(c, sd)
  99. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  100. ctx.So(err, convey.ShouldBeNil)
  101. ctx.So(res, convey.ShouldNotBeNil)
  102. })
  103. })
  104. }
  105. func TestDaoDelTokenCache(t *testing.T) {
  106. var (
  107. c = context.TODO()
  108. token = "5f263d1297aa40ea0252c0963e29c6eb"
  109. )
  110. convey.Convey("DelTokenCache", t, func(ctx convey.C) {
  111. err := d.DelTokenCache(c, token)
  112. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  113. ctx.So(err, convey.ShouldBeNil)
  114. })
  115. })
  116. }
  117. func TestDaoSetRefreshCache(t *testing.T) {
  118. var (
  119. c = context.TODO()
  120. refresh = &model.Refresh{
  121. Mid: 123,
  122. AppID: 430,
  123. Token: "b8b544c602557c27d454911d7ecc006c",
  124. Refresh: "5f263d1297aa40ea0252c0963e29c6e1",
  125. Expires: 1850953187,
  126. }
  127. )
  128. convey.Convey("SetRefreshCache", t, func(ctx convey.C) {
  129. err := d.SetRefreshCache(c, refresh)
  130. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  131. ctx.So(err, convey.ShouldBeNil)
  132. })
  133. })
  134. }
  135. func TestDaoRefreshCache(t *testing.T) {
  136. var (
  137. c = context.TODO()
  138. refresh = "5f263d1297aa40ea0252c0963e29c6e1"
  139. )
  140. convey.Convey("RefreshCache", t, func(ctx convey.C) {
  141. res, err := d.RefreshCache(c, refresh)
  142. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  143. ctx.So(err, convey.ShouldBeNil)
  144. ctx.So(res, convey.ShouldNotBeNil)
  145. })
  146. })
  147. }
  148. func TestDaoDelRefreshCache(t *testing.T) {
  149. var (
  150. c = context.TODO()
  151. refresh = "5f263d1297aa40ea0252c0963e29c6e0"
  152. )
  153. convey.Convey("DelRefreshCache", t, func(ctx convey.C) {
  154. err := d.DelRefreshCache(c, refresh)
  155. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  156. ctx.So(err, convey.ShouldBeNil)
  157. })
  158. })
  159. }
  160. func TestDaopingMC(t *testing.T) {
  161. var (
  162. c = context.TODO()
  163. )
  164. convey.Convey("pingMC", t, func(ctx convey.C) {
  165. err := d.pingMC(c)
  166. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  167. ctx.So(err, convey.ShouldBeNil)
  168. })
  169. })
  170. }