dynamic_redis_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/archive/api"
  5. dymdl "go-common/app/service/main/dynamic/model"
  6. "testing"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaokeyRegion(t *testing.T) {
  10. convey.Convey("keyRegion", t, func(ctx convey.C) {
  11. var (
  12. rid = int32(0)
  13. pn = int(0)
  14. ps = int(0)
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. p1 := keyRegion(rid, pn, ps)
  18. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  19. ctx.So(p1, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaokeyRegionTag(t *testing.T) {
  25. convey.Convey("keyRegionTag", t, func(ctx convey.C) {
  26. var (
  27. tagID = int64(0)
  28. rid = int32(0)
  29. pn = int(0)
  30. ps = int(0)
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. p1 := keyRegionTag(tagID, rid, pn, ps)
  34. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  35. ctx.So(p1, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoSetRegionBakCache(t *testing.T) {
  41. convey.Convey("SetRegionBakCache", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. rid = int32(0)
  45. pn = int(0)
  46. ps = int(0)
  47. rs = &dymdl.DynamicArcs3{}
  48. )
  49. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  50. err := d.SetRegionBakCache(c, rid, pn, ps, rs)
  51. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestDaoRegionBakCache(t *testing.T) {
  58. convey.Convey("RegionBakCache", t, func(ctx convey.C) {
  59. var (
  60. c = context.Background()
  61. rid = int32(0)
  62. pn = int(0)
  63. ps = int(0)
  64. )
  65. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  66. rs, err := d.RegionBakCache(c, rid, pn, ps)
  67. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. ctx.So(rs, convey.ShouldNotBeNil)
  70. })
  71. })
  72. })
  73. }
  74. func TestDaoSetRegionTagBakCache(t *testing.T) {
  75. convey.Convey("SetRegionTagBakCache", t, func(ctx convey.C) {
  76. var (
  77. c = context.Background()
  78. tagID = int64(0)
  79. rid = int32(0)
  80. pn = int(0)
  81. ps = int(0)
  82. rs = &dymdl.DynamicArcs3{}
  83. )
  84. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  85. err := d.SetRegionTagBakCache(c, tagID, rid, pn, ps, rs)
  86. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  87. ctx.So(err, convey.ShouldBeNil)
  88. })
  89. })
  90. })
  91. }
  92. func TestDaoRegionTagBakCache(t *testing.T) {
  93. convey.Convey("RegionTagBakCache", t, func(ctx convey.C) {
  94. var (
  95. c = context.Background()
  96. tagID = int64(0)
  97. rid = int32(0)
  98. pn = int(0)
  99. ps = int(0)
  100. )
  101. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  102. rs, err := d.RegionTagBakCache(c, tagID, rid, pn, ps)
  103. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  104. ctx.So(err, convey.ShouldBeNil)
  105. ctx.So(rs, convey.ShouldNotBeNil)
  106. })
  107. })
  108. })
  109. }
  110. func TestDaoSetRegionsBakCache(t *testing.T) {
  111. convey.Convey("SetRegionsBakCache", t, func(ctx convey.C) {
  112. var (
  113. c = context.Background()
  114. )
  115. rs := map[int32][]*api.Arc{1111: {{Aid: 1111}}}
  116. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  117. err := d.SetRegionsBakCache(c, rs)
  118. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  119. ctx.So(err, convey.ShouldBeNil)
  120. })
  121. })
  122. })
  123. }
  124. func TestDaoRegionsBakCache(t *testing.T) {
  125. convey.Convey("RegionsBakCache", t, func(ctx convey.C) {
  126. var (
  127. c = context.Background()
  128. )
  129. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  130. rs, err := d.RegionsBakCache(c)
  131. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  132. ctx.So(err, convey.ShouldBeNil)
  133. ctx.So(rs, convey.ShouldNotBeNil)
  134. })
  135. })
  136. })
  137. }
  138. func TestDaosetBakCache(t *testing.T) {
  139. convey.Convey("setBakCache", t, func(ctx convey.C) {
  140. var (
  141. c = context.Background()
  142. key = ""
  143. rs = &dymdl.DynamicArcs3{}
  144. )
  145. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  146. err := d.setBakCache(c, key, rs)
  147. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  148. ctx.So(err, convey.ShouldBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaobakCache(t *testing.T) {
  154. convey.Convey("bakCache", t, func(ctx convey.C) {
  155. var (
  156. c = context.Background()
  157. key = ""
  158. )
  159. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  160. rs, err := d.bakCache(c, key)
  161. ctx.Convey("Then err should be nil.rs should not be nil.", func(ctx convey.C) {
  162. ctx.So(err, convey.ShouldBeNil)
  163. ctx.So(rs, convey.ShouldNotBeNil)
  164. })
  165. })
  166. })
  167. }