memcache_test.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoexpKey(t *testing.T) {
  8. convey.Convey("expKey", t, func(convCtx convey.C) {
  9. var (
  10. mid = int64(0)
  11. )
  12. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  13. p1 := expKey(mid)
  14. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  15. convCtx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestDaomcBaseKey(t *testing.T) {
  21. convey.Convey("mcBaseKey", t, func(convCtx convey.C) {
  22. var (
  23. mid = int64(0)
  24. )
  25. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  26. key := d.mcBaseKey(mid)
  27. convCtx.Convey("Then key should not be nil.", func(convCtx convey.C) {
  28. convCtx.So(key, convey.ShouldNotBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestDaomoralKey(t *testing.T) {
  34. convey.Convey("moralKey", t, func(convCtx convey.C) {
  35. var (
  36. mid = int64(0)
  37. )
  38. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  39. key := d.moralKey(mid)
  40. convCtx.Convey("Then key should not be nil.", func(convCtx convey.C) {
  41. convCtx.So(key, convey.ShouldNotBeNil)
  42. })
  43. })
  44. })
  45. }
  46. func TestDaoSetStartCache(t *testing.T) {
  47. convey.Convey("SetStartCache", t, func(convCtx convey.C) {
  48. var (
  49. c = context.Background()
  50. mid = int64(0)
  51. key = ""
  52. )
  53. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  54. err := d.SetStartCache(c, mid, key)
  55. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  56. convCtx.So(err, convey.ShouldBeNil)
  57. })
  58. })
  59. })
  60. }
  61. func TestDaoDelMoralCache(t *testing.T) {
  62. convey.Convey("DelMoralCache", t, func(convCtx convey.C) {
  63. var (
  64. c = context.Background()
  65. mid = int64(0)
  66. )
  67. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  68. err := d.DelMoralCache(c, mid)
  69. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  70. convCtx.So(err, convey.ShouldBeNil)
  71. })
  72. })
  73. })
  74. }
  75. func TestDaoDelBaseInfoCache(t *testing.T) {
  76. convey.Convey("DelBaseInfoCache", t, func(convCtx convey.C) {
  77. var (
  78. c = context.Background()
  79. mid = int64(0)
  80. )
  81. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  82. err := d.DelBaseInfoCache(c, mid)
  83. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  84. convCtx.So(err, convey.ShouldBeNil)
  85. })
  86. })
  87. })
  88. }
  89. func TestDaoSetExpCache(t *testing.T) {
  90. convey.Convey("SetExpCache", t, func(convCtx convey.C) {
  91. var (
  92. c = context.Background()
  93. mid = int64(0)
  94. exp = int64(0)
  95. )
  96. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  97. err := d.SetExpCache(c, mid, exp)
  98. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  99. convCtx.So(err, convey.ShouldBeNil)
  100. })
  101. })
  102. })
  103. }
  104. func TestDaorealnameInfoKey(t *testing.T) {
  105. convey.Convey("realnameInfoKey", t, func(convCtx convey.C) {
  106. var (
  107. mid = int64(0)
  108. )
  109. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  110. p1 := realnameInfoKey(mid)
  111. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  112. convCtx.So(p1, convey.ShouldNotBeNil)
  113. })
  114. })
  115. })
  116. }
  117. func TestDaorealnameApplyStatusKey(t *testing.T) {
  118. convey.Convey("realnameApplyStatusKey", t, func(convCtx convey.C) {
  119. var (
  120. mid = int64(0)
  121. )
  122. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  123. p1 := realnameApplyStatusKey(mid)
  124. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  125. convCtx.So(p1, convey.ShouldNotBeNil)
  126. })
  127. })
  128. })
  129. }
  130. func TestDaoDeleteRealnameCache(t *testing.T) {
  131. convey.Convey("DeleteRealnameCache", t, func(convCtx convey.C) {
  132. var (
  133. c = context.Background()
  134. mid = int64(0)
  135. )
  136. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  137. err := d.DeleteRealnameCache(c, mid)
  138. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  139. convCtx.So(err, convey.ShouldBeNil)
  140. })
  141. })
  142. })
  143. }