mysql_test.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/playlist/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoplArcHit(t *testing.T) {
  9. var (
  10. pid = int64(1)
  11. )
  12. convey.Convey("plArcHit", t, func(ctx convey.C) {
  13. p1 := plArcHit(pid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoVideo(t *testing.T) {
  20. var (
  21. c = context.Background()
  22. pid = int64(1)
  23. aid = int64(13825646)
  24. )
  25. convey.Convey("Video", t, func(ctx convey.C) {
  26. res, err := d.Video(c, pid, aid)
  27. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  28. ctx.So(err, convey.ShouldBeNil)
  29. ctx.So(res, convey.ShouldNotBeNil)
  30. })
  31. })
  32. }
  33. func TestDaoVideos(t *testing.T) {
  34. var (
  35. c = context.Background()
  36. pid = int64(1)
  37. )
  38. convey.Convey("Videos", t, func(ctx convey.C) {
  39. _, err := d.Videos(c, pid)
  40. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. })
  43. })
  44. }
  45. func TestDaoAddArc(t *testing.T) {
  46. var (
  47. c = context.Background()
  48. pid = int64(1)
  49. aid = int64(3)
  50. sort = int64(0)
  51. desc = "abc"
  52. )
  53. convey.Convey("AddArc", t, func(ctx convey.C) {
  54. lastID, err := d.AddArc(c, pid, aid, sort, desc)
  55. ctx.Convey("Then err should be nil.lastID should not be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldBeNil)
  57. ctx.So(lastID, convey.ShouldNotBeNil)
  58. })
  59. })
  60. }
  61. func TestDaoBatchAddArc(t *testing.T) {
  62. var (
  63. c = context.Background()
  64. pid = int64(1)
  65. arcSorts = []*model.ArcSort{}
  66. )
  67. convey.Convey("BatchAddArc", t, func(ctx convey.C) {
  68. arcSorts = append(arcSorts, &model.ArcSort{Aid: 13825646, Desc: "abc", Sort: 100})
  69. lastID, err := d.BatchAddArc(c, pid, arcSorts)
  70. ctx.Convey("Then err should be nil.lastID should not be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. ctx.So(lastID, convey.ShouldNotBeNil)
  73. })
  74. })
  75. }
  76. func TestDaoDelArc(t *testing.T) {
  77. var (
  78. c = context.Background()
  79. pid = int64(1)
  80. aid = int64(13825646)
  81. )
  82. convey.Convey("DelArc", t, func(ctx convey.C) {
  83. affected, err := d.DelArc(c, pid, aid)
  84. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. ctx.So(affected, convey.ShouldNotBeNil)
  87. })
  88. })
  89. }
  90. func TestDaoBatchDelArc(t *testing.T) {
  91. var (
  92. c = context.Background()
  93. pid = int64(1)
  94. aids = []int64{13825646, 11, 22, 33}
  95. )
  96. convey.Convey("BatchDelArc", t, func(ctx convey.C) {
  97. affected, err := d.BatchDelArc(c, pid, aids)
  98. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  99. ctx.So(err, convey.ShouldBeNil)
  100. ctx.So(affected, convey.ShouldNotBeNil)
  101. })
  102. })
  103. }
  104. func TestDaoUpdateArcDesc(t *testing.T) {
  105. var (
  106. c = context.Background()
  107. pid = int64(1)
  108. aid = int64(13825646)
  109. desc = "abc"
  110. )
  111. convey.Convey("UpdateArcDesc", t, func(ctx convey.C) {
  112. affected, err := d.UpdateArcDesc(c, pid, aid, desc)
  113. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  114. ctx.So(err, convey.ShouldBeNil)
  115. ctx.So(affected, convey.ShouldNotBeNil)
  116. })
  117. })
  118. }
  119. func TestDaoUpdateArcSort(t *testing.T) {
  120. var (
  121. c = context.Background()
  122. pid = int64(1)
  123. aid = int64(13825646)
  124. sort = int64(0)
  125. )
  126. convey.Convey("UpdateArcSort", t, func(ctx convey.C) {
  127. affected, err := d.UpdateArcSort(c, pid, aid, sort)
  128. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(affected, convey.ShouldNotBeNil)
  131. })
  132. })
  133. }
  134. func TestDaoBatchUpdateArcSort(t *testing.T) {
  135. var (
  136. c = context.Background()
  137. pid = int64(1)
  138. arcSorts = []*model.ArcSort{}
  139. )
  140. convey.Convey("BatchUpdateArcSort", t, func(ctx convey.C) {
  141. arcSorts = append(arcSorts, &model.ArcSort{Aid: 1, Desc: "abc"})
  142. affected, err := d.BatchUpdateArcSort(c, pid, arcSorts)
  143. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  144. ctx.So(err, convey.ShouldBeNil)
  145. ctx.So(affected, convey.ShouldNotBeNil)
  146. })
  147. })
  148. }
  149. func TestDaoAdd(t *testing.T) {
  150. var (
  151. c = context.Background()
  152. mid = int64(2)
  153. fid = int64(1)
  154. )
  155. convey.Convey("Add", t, func(ctx convey.C) {
  156. lastID, err := d.Add(c, mid, fid)
  157. ctx.Convey("Then err should be nil.lastID should not be nil.", func(ctx convey.C) {
  158. ctx.So(err, convey.ShouldBeNil)
  159. ctx.So(lastID, convey.ShouldNotBeNil)
  160. })
  161. })
  162. }
  163. func TestDaoDel(t *testing.T) {
  164. var (
  165. c = context.Background()
  166. pid = int64(1)
  167. )
  168. convey.Convey("Del", t, func(ctx convey.C) {
  169. affected, err := d.Del(c, pid)
  170. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  171. ctx.So(err, convey.ShouldBeNil)
  172. ctx.So(affected, convey.ShouldNotBeNil)
  173. })
  174. })
  175. }
  176. func TestDaoUpdate(t *testing.T) {
  177. var (
  178. c = context.Background()
  179. pid = int64(1)
  180. )
  181. convey.Convey("Update", t, func(ctx convey.C) {
  182. affected, err := d.Update(c, pid)
  183. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  184. ctx.So(err, convey.ShouldBeNil)
  185. ctx.So(affected, convey.ShouldNotBeNil)
  186. })
  187. })
  188. }
  189. func TestDaoPlsByMid(t *testing.T) {
  190. var (
  191. c = context.Background()
  192. mid = int64(2)
  193. )
  194. convey.Convey("PlsByMid", t, func(ctx convey.C) {
  195. res, err := d.PlsByMid(c, mid)
  196. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  197. ctx.So(err, convey.ShouldBeNil)
  198. ctx.So(res, convey.ShouldNotBeNil)
  199. })
  200. })
  201. }
  202. func TestDaoPlsByPid(t *testing.T) {
  203. var (
  204. c = context.Background()
  205. pids = []int64{1, 2, 3}
  206. )
  207. convey.Convey("PlsByPid", t, func(ctx convey.C) {
  208. _, err := d.PlsByPid(c, pids)
  209. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  210. ctx.So(err, convey.ShouldBeNil)
  211. })
  212. })
  213. }
  214. func TestDaoPlByPid(t *testing.T) {
  215. var (
  216. c = context.Background()
  217. pid = int64(1)
  218. )
  219. convey.Convey("PlByPid", t, func(ctx convey.C) {
  220. res, err := d.PlByPid(c, pid)
  221. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  222. ctx.So(err, convey.ShouldBeNil)
  223. ctx.So(res, convey.ShouldNotBeNil)
  224. })
  225. })
  226. }