new_video_test.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. package archive
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. "go-common/app/service/main/videoup/model/archive"
  7. )
  8. func TestDao_TxAddVideoCid(t *testing.T) {
  9. var (
  10. c = context.Background()
  11. tx, _ = d.BeginTran(c)
  12. v = &archive.Video{
  13. Aid: 23333,
  14. Cid: 12121,
  15. Title: "sssss",
  16. }
  17. )
  18. Convey("TxAddVideoCid", t, func(ctx C) {
  19. _, err := d.TxAddVideoCid(tx, v)
  20. if err != nil {
  21. tx.Rollback()
  22. } else {
  23. tx.Commit()
  24. }
  25. So(err, ShouldBeNil)
  26. })
  27. }
  28. func TestDao_AddNewVideo(t *testing.T) {
  29. var (
  30. c = context.Background()
  31. v = &archive.Video{
  32. Aid: 23333,
  33. Cid: 12121,
  34. Title: "sssss",
  35. }
  36. )
  37. Convey("AddNewVideo", t, func(ctx C) {
  38. _, err := d.AddNewVideo(c, v)
  39. So(err, ShouldBeNil)
  40. })
  41. }
  42. func TestDao_TxAddNewVideo(t *testing.T) {
  43. var (
  44. c = context.Background()
  45. v = &archive.Video{
  46. Aid: 23333,
  47. Cid: 12121,
  48. Title: "sssss",
  49. }
  50. tx, _ = d.BeginTran(c)
  51. )
  52. Convey("TxAddNewVideo", t, func(ctx C) {
  53. _, err := d.TxAddNewVideo(tx, v)
  54. if err != nil {
  55. tx.Rollback()
  56. } else {
  57. tx.Commit()
  58. }
  59. So(err, ShouldBeNil)
  60. })
  61. }
  62. func TestDao_TxAddVideoRelation(t *testing.T) {
  63. var (
  64. c = context.Background()
  65. v = &archive.Video{
  66. Aid: 23333,
  67. Cid: 12121,
  68. Title: "sssss",
  69. }
  70. tx, _ = d.BeginTran(c)
  71. )
  72. Convey("TxAddVideoRelation", t, func(ctx C) {
  73. _, err := d.TxAddVideoRelation(tx, v)
  74. if err != nil {
  75. tx.Rollback()
  76. } else {
  77. tx.Commit()
  78. }
  79. So(err, ShouldBeNil)
  80. })
  81. }
  82. func TestDao_TxUpVideoRelation(t *testing.T) {
  83. var (
  84. c = context.Background()
  85. v = &archive.Video{
  86. Aid: 23333,
  87. Cid: 12121,
  88. Title: "sssss",
  89. }
  90. tx, _ = d.BeginTran(c)
  91. )
  92. Convey("TxUpVideoRelation", t, func(ctx C) {
  93. _, err := d.TxUpVideoRelation(tx, v)
  94. if err != nil {
  95. tx.Rollback()
  96. } else {
  97. tx.Commit()
  98. }
  99. So(err, ShouldBeNil)
  100. })
  101. }
  102. func TestDao_TxUpRelationState(t *testing.T) {
  103. var (
  104. c = context.Background()
  105. tx, _ = d.BeginTran(c)
  106. )
  107. Convey("TxUpRelationState", t, func(ctx C) {
  108. _, err := d.TxUpRelationState(tx, 23333, 1212, 0)
  109. if err != nil {
  110. tx.Rollback()
  111. } else {
  112. tx.Commit()
  113. }
  114. So(err, ShouldBeNil)
  115. })
  116. }
  117. func TestDao_TxUpVdoStatus(t *testing.T) {
  118. var (
  119. c = context.Background()
  120. tx, _ = d.BeginTran(c)
  121. )
  122. Convey("TxUpVdoStatus", t, func(ctx C) {
  123. _, err := d.TxUpVdoStatus(tx, 1212, 0)
  124. if err != nil {
  125. tx.Rollback()
  126. } else {
  127. tx.Commit()
  128. }
  129. So(err, ShouldBeNil)
  130. })
  131. }
  132. func TestDao_TxUpNewVideo(t *testing.T) {
  133. var (
  134. c = context.Background()
  135. tx, _ = d.BeginTran(c)
  136. v = &archive.Video{
  137. Aid: 23333,
  138. Cid: 12121,
  139. Title: "sssss",
  140. }
  141. )
  142. Convey("TxUpNewVideo", t, func(ctx C) {
  143. _, err := d.TxUpNewVideo(tx, v)
  144. if err != nil {
  145. tx.Rollback()
  146. } else {
  147. tx.Commit()
  148. }
  149. So(err, ShouldBeNil)
  150. })
  151. }
  152. func TestDao_NewCidsByFns(t *testing.T) {
  153. var (
  154. c = context.Background()
  155. vs = []*archive.Video{{
  156. Filename: "1212121243gf",
  157. }}
  158. )
  159. Convey("NewCidsByFns", t, func(ctx C) {
  160. _, err := d.NewCidsByFns(c, vs)
  161. So(err, ShouldBeNil)
  162. })
  163. }
  164. func TestDao_CheckNewVideosTimeout(t *testing.T) {
  165. var (
  166. c = context.Background()
  167. fs = []string{"1212121243gf"}
  168. )
  169. Convey("CheckNewVideosTimeout", t, func(ctx C) {
  170. _, _, err := d.CheckNewVideosTimeout(c, fs)
  171. So(err, ShouldBeNil)
  172. })
  173. }
  174. func TestDao_ParseDimensions(t *testing.T) {
  175. Convey("CheckNewVideosTimeout", t, func(ctx C) {
  176. _, err := d.parseDimensions("1,2,3")
  177. So(err, ShouldBeNil)
  178. })
  179. }
  180. func TestArchiveNewVideoFn(t *testing.T) {
  181. var (
  182. c = context.Background()
  183. filename = "23333333333"
  184. )
  185. Convey("NewVideoFn", t, func(ctx C) {
  186. _, err := d.NewVideoFn(c, filename)
  187. ctx.Convey("Then err should be nil.v should not be nil.", func(ctx C) {
  188. ctx.So(err, ShouldBeNil)
  189. })
  190. })
  191. }
  192. func TestArchiveNewVideoByFn(t *testing.T) {
  193. var (
  194. c = context.Background()
  195. filename = "23333333333"
  196. )
  197. Convey("NewVideoByFn", t, func(ctx C) {
  198. _, err := d.NewVideoByFn(c, filename)
  199. ctx.Convey("Then err should be nil.v should not be nil.", func(ctx C) {
  200. ctx.So(err, ShouldBeNil)
  201. })
  202. })
  203. }
  204. func TestArchiveSimpleArcVideos(t *testing.T) {
  205. var (
  206. c = context.Background()
  207. aid = int64(2333333)
  208. )
  209. Convey("SimpleArcVideos", t, func(ctx C) {
  210. _, err := d.SimpleArcVideos(c, aid)
  211. ctx.Convey("Then err should be nil.vs should not be nil.", func(ctx C) {
  212. ctx.So(err, ShouldBeNil)
  213. })
  214. })
  215. }
  216. func TestArchiveNewVideos(t *testing.T) {
  217. var (
  218. c = context.Background()
  219. aid = int64(2333333)
  220. )
  221. Convey("NewVideos", t, func(ctx C) {
  222. _, err := d.NewVideos(c, aid)
  223. ctx.Convey("Then err should be nil.vs should not be nil.", func(ctx C) {
  224. ctx.So(err, ShouldBeNil)
  225. })
  226. })
  227. }
  228. func TestArchiveNewVideoMap(t *testing.T) {
  229. var (
  230. c = context.Background()
  231. aid = int64(23333)
  232. )
  233. Convey("NewVideoMap", t, func(ctx C) {
  234. _, _, err := d.NewVideoMap(c, aid)
  235. ctx.Convey("Then err should be nil.vm,cvm should not be nil.", func(ctx C) {
  236. ctx.So(err, ShouldBeNil)
  237. })
  238. })
  239. }
  240. func TestArchiveNewVideoByCID(t *testing.T) {
  241. var (
  242. c = context.Background()
  243. cid = int64(23333)
  244. )
  245. Convey("NewVideoByCID", t, func(ctx C) {
  246. _, err := d.NewVideoByCID(c, cid)
  247. ctx.Convey("Then err should be nil.v should not be nil.", func(ctx C) {
  248. ctx.So(err, ShouldBeNil)
  249. })
  250. })
  251. }
  252. func TestArchiveNewVideosByCID(t *testing.T) {
  253. var (
  254. c = context.Background()
  255. cids = []int64{23333}
  256. )
  257. Convey("NewVideosByCID", t, func(ctx C) {
  258. _, err := d.NewVideosByCID(c, cids)
  259. ctx.Convey("Then err should be nil.vm should not be nil.", func(ctx C) {
  260. ctx.So(err, ShouldBeNil)
  261. })
  262. })
  263. }
  264. func TestArchiveNewVideosByFn(t *testing.T) {
  265. var (
  266. c = context.Background()
  267. fns = []string{"23333"}
  268. )
  269. Convey("NewVideosByFn", t, func(ctx C) {
  270. _, err := d.NewVideosByFn(c, fns)
  271. ctx.Convey("Then err should be nil.vm should not be nil.", func(ctx C) {
  272. ctx.So(err, ShouldBeNil)
  273. })
  274. })
  275. }
  276. func TestArchiveNewVideosReason(t *testing.T) {
  277. var (
  278. c = context.Background()
  279. aid = int64(23333)
  280. )
  281. Convey("NewVideosReason", t, func(ctx C) {
  282. _, err := d.NewVideosReason(c, aid)
  283. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx C) {
  284. ctx.So(err, ShouldBeNil)
  285. })
  286. })
  287. }