task_weight_test.go 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/videoup-task/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoGetMaxWeight(t *testing.T) {
  9. convey.Convey("GetMaxWeight", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. max, err := d.GetMaxWeight(c)
  15. ctx.Convey("Then err should be nil.max should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(max, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoUpCwAfterAdd(t *testing.T) {
  23. convey.Convey("UpCwAfterAdd", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. id = int64(0)
  27. desc = ""
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. rows, err := d.UpCwAfterAdd(c, id, desc)
  31. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(rows, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoInWeightConf(t *testing.T) {
  39. convey.Convey("InWeightConf", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. mcases map[int64]*model.WCItem
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. err := d.InWeightConf(c, mcases)
  46. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestDaoDelWeightConf(t *testing.T) {
  53. convey.Convey("DelWeightConf", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. id = int64(0)
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. rows, err := d.DelWeightConf(c, id)
  60. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. ctx.So(rows, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoListWeightConf(t *testing.T) {
  68. convey.Convey("ListWeightConf", t, func(ctx convey.C) {
  69. var (
  70. c = context.Background()
  71. cf = &model.Confs{}
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. _, err := d.ListWeightConf(c, cf)
  75. ctx.Convey("Then err should be nil.citems should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. })
  78. })
  79. })
  80. }
  81. func TestDaoWeightConf(t *testing.T) {
  82. convey.Convey("WeightConf", t, func(ctx convey.C) {
  83. var (
  84. c = context.Background()
  85. )
  86. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  87. items, err := d.WeightConf(c)
  88. ctx.Convey("Then err should be nil.items should not be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldBeNil)
  90. ctx.So(items, convey.ShouldNotBeNil)
  91. })
  92. })
  93. })
  94. }
  95. func TestDaokey(t *testing.T) {
  96. convey.Convey("key", t, func(ctx convey.C) {
  97. var (
  98. id = int64(0)
  99. )
  100. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  101. p1 := key(id)
  102. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  103. ctx.So(p1, convey.ShouldNotBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoGetWeightRedis(t *testing.T) {
  109. convey.Convey("GetWeightRedis", t, func(ctx convey.C) {
  110. var (
  111. c = context.Background()
  112. ids = []int64{}
  113. )
  114. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  115. mcases, err := d.GetWeightRedis(c, ids)
  116. ctx.Convey("Then err should be nil.mcases should not be nil.", func(ctx convey.C) {
  117. ctx.So(err, convey.ShouldBeNil)
  118. ctx.So(mcases, convey.ShouldNotBeNil)
  119. })
  120. })
  121. })
  122. }
  123. func TestDaoWeightVC(t *testing.T) {
  124. convey.Convey("WeightVC", t, func(ctx convey.C) {
  125. var (
  126. c = context.Background()
  127. )
  128. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  129. wvc, err := d.WeightVC(c)
  130. ctx.Convey("Then err should be nil.wvc should not be nil.", func(ctx convey.C) {
  131. ctx.So(err, convey.ShouldBeNil)
  132. ctx.So(wvc, convey.ShouldNotBeNil)
  133. })
  134. })
  135. })
  136. }
  137. func TestDaoSetWeightVC(t *testing.T) {
  138. convey.Convey("SetWeightVC", t, func(ctx convey.C) {
  139. var (
  140. c = context.Background()
  141. wvc = &model.WeightVC{}
  142. desc = ""
  143. )
  144. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  145. rows, err := d.SetWeightVC(c, wvc, desc)
  146. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  147. ctx.So(err, convey.ShouldBeNil)
  148. ctx.So(rows, convey.ShouldNotBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaoInWeightVC(t *testing.T) {
  154. convey.Convey("InWeightVC", t, func(ctx convey.C) {
  155. var (
  156. c = context.Background()
  157. wvc = &model.WeightVC{}
  158. desc = ""
  159. )
  160. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  161. rows, err := d.InWeightVC(c, wvc, desc)
  162. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  163. ctx.So(err, convey.ShouldBeNil)
  164. ctx.So(rows, convey.ShouldNotBeNil)
  165. })
  166. })
  167. })
  168. }
  169. func TestDaoLWConfigHelp(t *testing.T) {
  170. convey.Convey("LWConfigHelp", t, func(ctx convey.C) {
  171. var (
  172. c = context.Background()
  173. )
  174. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  175. _, err := d.LWConfigHelp(c, []int64{1})
  176. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  177. ctx.So(err, convey.ShouldBeNil)
  178. })
  179. })
  180. })
  181. }
  182. func TestDaoSetWeightRedis(t *testing.T) {
  183. convey.Convey("SetWeightRedis", t, func(ctx convey.C) {
  184. var (
  185. c = context.Background()
  186. mcases = map[int64]*model.TaskPriority{
  187. 0: &model.TaskPriority{},
  188. }
  189. )
  190. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  191. err := d.SetWeightRedis(c, mcases)
  192. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. })
  195. })
  196. })
  197. }