task_redis_test.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/job/main/aegis/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoSetTask(t *testing.T) {
  10. convey.Convey("SetTask", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. err1 := d.SetTask(c, task1)
  16. err2 := d.SetTask(c, task2)
  17. err3 := d.SetTask(c, task3)
  18. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  19. ctx.So(err1, convey.ShouldBeNil)
  20. ctx.So(err2, convey.ShouldBeNil)
  21. ctx.So(err3, convey.ShouldBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoGetTask(t *testing.T) {
  27. convey.Convey("GetTask", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. id = int64(1)
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. task, err := d.GetTask(c, id)
  34. ctx.Convey("Then err should be nil.task should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(task, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestDaoPushPublicTask(t *testing.T) {
  42. convey.Convey("PushPublicTask", t, func(ctx convey.C) {
  43. var (
  44. c = context.Background()
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. err := d.PushPublicTask(c, task1, task2, task3)
  48. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. })
  53. }
  54. func TestDaoRemovePublicTask(t *testing.T) {
  55. convey.Convey("RemovePublicTask", t, func(ctx convey.C) {
  56. var (
  57. c = context.Background()
  58. )
  59. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  60. err := d.RemovePublicTask(c, 1, 1, 1)
  61. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  62. ctx.So(err, convey.ShouldBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoPushPersonalTask(t *testing.T) {
  68. convey.Convey("PushPersonalTask", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. businessID = int64(1)
  72. flowID = int64(1)
  73. uid = int64(1)
  74. taskid = int64(1)
  75. )
  76. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  77. err := d.PushPersonalTask(c, businessID, flowID, uid, taskid)
  78. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. })
  81. })
  82. })
  83. }
  84. func TestDaoRemovePersonalTask(t *testing.T) {
  85. convey.Convey("RemovePersonalTask", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. businessID = int64(1)
  89. flowID = int64(1)
  90. uid = int64(1)
  91. taskid = int64(1)
  92. )
  93. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  94. err := d.RemovePersonalTask(c, businessID, flowID, uid, taskid)
  95. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  96. ctx.So(err, convey.ShouldBeNil)
  97. })
  98. })
  99. })
  100. }
  101. func TestDaoPushDelayTask(t *testing.T) {
  102. convey.Convey("PushDelayTask", t, func(ctx convey.C) {
  103. var (
  104. c = context.Background()
  105. businessID = int64(1)
  106. flowID = int64(1)
  107. uid = int64(1)
  108. taskid = int64(1)
  109. )
  110. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  111. err := d.PushDelayTask(c, businessID, flowID, uid, taskid)
  112. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  113. ctx.So(err, convey.ShouldBeNil)
  114. })
  115. })
  116. })
  117. }
  118. func TestDaoRemoveDelayTask(t *testing.T) {
  119. convey.Convey("RemoveDelayTask", t, func(ctx convey.C) {
  120. var (
  121. c = context.Background()
  122. businessID = int64(1)
  123. flowID = int64(1)
  124. uid = int64(1)
  125. taskid = int64(1)
  126. )
  127. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  128. err := d.RemoveDelayTask(c, businessID, flowID, uid, taskid)
  129. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  130. ctx.So(err, convey.ShouldBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestDaoSetWeight(t *testing.T) {
  136. convey.Convey("SetWeight", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. businessID = int64(1)
  140. flowID = int64(1)
  141. id = int64(1)
  142. weight = int64(10)
  143. )
  144. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  145. d.SetWeight(c, businessID, flowID, id, weight)
  146. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  147. })
  148. })
  149. })
  150. }
  151. func TestDaoGetWeight(t *testing.T) {
  152. convey.Convey("GetWeight", t, func(ctx convey.C) {
  153. })
  154. }
  155. func TestDaoTopWeights(t *testing.T) {
  156. convey.Convey("TopWeights", t, func(ctx convey.C) {
  157. })
  158. }
  159. func TestDaoCreateUnionSet(t *testing.T) {
  160. convey.Convey("CreateUnionSet", t, func(ctx convey.C) {
  161. var (
  162. c = context.Background()
  163. businessID = int64(1)
  164. flowID = int64(1)
  165. )
  166. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  167. err := d.CreateUnionSet(c, businessID, flowID)
  168. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  169. ctx.So(err, convey.ShouldBeNil)
  170. })
  171. })
  172. })
  173. }
  174. func TestDaoRangeUinonSet(t *testing.T) {
  175. convey.Convey("RangeUinonSet", t, func(ctx convey.C) {
  176. })
  177. }
  178. func TestDaoDeleteUinonSet(t *testing.T) {
  179. convey.Convey("DeleteUinonSet", t, func(ctx convey.C) {
  180. var (
  181. c = context.Background()
  182. businessID = int64(1)
  183. flowID = int64(1)
  184. )
  185. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  186. err := d.DeleteUinonSet(c, businessID, flowID)
  187. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  188. ctx.So(err, convey.ShouldBeNil)
  189. })
  190. })
  191. })
  192. }
  193. func TestDaoIncresByField(t *testing.T) {
  194. convey.Convey("IncresByField", t, func(ctx convey.C) {
  195. var (
  196. c = context.Background()
  197. )
  198. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  199. err := d.IncresByField(c, 1, 1, 1, model.Dispatch, 1)
  200. err = d.IncresByField(c, 1, 1, 1, model.Release, 1)
  201. err = d.IncresByField(c, 1, 1, 1, model.Submit, 1)
  202. err = d.IncresByField(c, 1, 1, 1, model.Delay, 1)
  203. err = d.IncresByField(c, 1, 1, 1, fmt.Sprintf(model.RscState, 1), 1)
  204. err = d.IncresByField(c, 1, 1, 1, model.UseTime, 112)
  205. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  206. ctx.So(err, convey.ShouldBeNil)
  207. })
  208. })
  209. })
  210. }
  211. func TestDaoFlushReport(t *testing.T) {
  212. convey.Convey("FlushReport", t, func(ctx convey.C) {
  213. var (
  214. c = context.Background()
  215. )
  216. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  217. data, err := d.FlushReport(c)
  218. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  219. ctx.So(err, convey.ShouldBeNil)
  220. for key, val := range data {
  221. fmt.Println("key:", key)
  222. fmt.Println("val:", string(val))
  223. }
  224. })
  225. })
  226. })
  227. }