redis_test.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/credit/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaovoteIndexKey(t *testing.T) {
  9. convey.Convey("voteIndexKey", t, func(ctx convey.C) {
  10. var (
  11. cid = int64(1)
  12. otype = int8(1)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. p1 := voteIndexKey(cid, otype)
  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 TestDaocaseIndexKey(t *testing.T) {
  23. convey.Convey("caseIndexKey", t, func(ctx convey.C) {
  24. var (
  25. cid = int64(1)
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. p1 := caseIndexKey(cid)
  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 TestDaoblockIndexKey(t *testing.T) {
  36. convey.Convey("blockIndexKey", t, func(ctx convey.C) {
  37. var (
  38. otype = int64(1)
  39. btype = int64(1)
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. p1 := blockIndexKey(otype, btype)
  43. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  44. ctx.So(p1, convey.ShouldNotBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoDelCaseIdx(t *testing.T) {
  50. convey.Convey("DelCaseIdx", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. cid = int64(1)
  54. )
  55. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  56. err := d.DelCaseIdx(c, cid)
  57. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDaoDelBlockedInfoIdx(t *testing.T) {
  64. convey.Convey("DelBlockedInfoIdx", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. bl = &model.BlockedInfo{}
  68. )
  69. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  70. err := d.DelBlockedInfoIdx(c, bl)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoAddBlockInfoIdx(t *testing.T) {
  78. convey.Convey("AddBlockInfoIdx", t, func(ctx convey.C) {
  79. var (
  80. c = context.Background()
  81. bl = &model.BlockedInfo{MTime: "2018-11-14 00:00:00"}
  82. )
  83. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  84. err := d.AddBlockInfoIdx(c, bl)
  85. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  86. ctx.So(err, convey.ShouldBeNil)
  87. })
  88. })
  89. })
  90. }
  91. func TestDaoDelVoteIdx(t *testing.T) {
  92. convey.Convey("DelVoteIdx", t, func(ctx convey.C) {
  93. var (
  94. c = context.Background()
  95. cid = int64(1)
  96. )
  97. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  98. err := d.DelVoteIdx(c, cid)
  99. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  100. ctx.So(err, convey.ShouldBeNil)
  101. })
  102. })
  103. })
  104. }
  105. func TestDaoSetGrantCase(t *testing.T) {
  106. convey.Convey("SetGrantCase", t, func(ctx convey.C) {
  107. var (
  108. c = context.Background()
  109. mcases = make(map[int64]*model.SimCase)
  110. )
  111. mcases[1] = &model.SimCase{}
  112. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  113. err := d.SetGrantCase(c, mcases)
  114. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  115. ctx.So(err, convey.ShouldBeNil)
  116. })
  117. })
  118. })
  119. }
  120. func TestDaoDelGrantCase(t *testing.T) {
  121. convey.Convey("DelGrantCase", t, func(ctx convey.C) {
  122. var (
  123. c = context.Background()
  124. cids = []int64{1, 2}
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. err := d.DelGrantCase(c, cids)
  128. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. })
  131. })
  132. })
  133. }
  134. func TestDaoTotalGrantCase(t *testing.T) {
  135. convey.Convey("TotalGrantCase", t, func(ctx convey.C) {
  136. var (
  137. c = context.Background()
  138. )
  139. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  140. count, err := d.TotalGrantCase(c)
  141. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  142. ctx.So(err, convey.ShouldBeNil)
  143. ctx.So(count, convey.ShouldNotBeNil)
  144. })
  145. })
  146. })
  147. }
  148. func TestDaoGrantCases(t *testing.T) {
  149. convey.Convey("GrantCases", t, func(ctx convey.C) {
  150. var (
  151. c = context.Background()
  152. )
  153. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  154. _, err := d.GrantCases(c)
  155. ctx.Convey("Then err should be nil.cids should not be nil.", func(ctx convey.C) {
  156. ctx.So(err, convey.ShouldBeNil)
  157. // ctx.So(cids, convey.ShouldNotBeNil)
  158. })
  159. })
  160. })
  161. }