archive_test.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. package archive
  2. import (
  3. "context"
  4. xsql "database/sql"
  5. "fmt"
  6. "reflect"
  7. "time"
  8. "go-common/app/job/main/videoup/model/archive"
  9. "go-common/library/database/sql"
  10. "testing"
  11. "github.com/bouk/monkey"
  12. _ "github.com/go-sql-driver/mysql"
  13. . "github.com/smartystreets/goconvey/convey"
  14. )
  15. func Test_Archive(t *testing.T) {
  16. var (
  17. c = context.TODO()
  18. err error
  19. sub *archive.Archive
  20. )
  21. Convey("Tool", t, WithDao(func(d *Dao) {
  22. sub, err = d.Archive(c, 23333)
  23. So(err, ShouldBeNil)
  24. So(sub, ShouldBeNil)
  25. }))
  26. }
  27. func Test_UpperArcStateMap(t *testing.T) {
  28. var (
  29. c = context.TODO()
  30. err error
  31. )
  32. Convey("UpperArcStateMap", t, WithDao(func(d *Dao) {
  33. _, err = d.UpperArcStateMap(c, 23333)
  34. So(err, ShouldBeNil)
  35. }))
  36. }
  37. func Test_UpDelayRound(t *testing.T) {
  38. var (
  39. c = context.TODO()
  40. err error
  41. mt1, mt2 time.Time
  42. )
  43. Convey("UpDelayRound", t, WithDao(func(d *Dao) {
  44. _, err = d.UpDelayRound(c, mt1, mt2)
  45. So(err, ShouldBeNil)
  46. }))
  47. }
  48. func TestDao_TxUpState(t *testing.T) {
  49. var (
  50. c = context.Background()
  51. tx, _ = d.BeginTran(c)
  52. )
  53. Convey("TxUpState", t, func(ctx C) {
  54. _, err := d.TxUpState(tx, 2333, 0)
  55. if err != nil {
  56. tx.Rollback()
  57. } else {
  58. tx.Commit()
  59. }
  60. So(err, ShouldBeNil)
  61. })
  62. }
  63. func TestDao_TxUpAccess(t *testing.T) {
  64. var (
  65. c = context.Background()
  66. tx, _ = d.BeginTran(c)
  67. )
  68. Convey("TxUpAccess", t, func(ctx C) {
  69. _, err := d.TxUpAccess(tx, 2333, 0)
  70. if err != nil {
  71. tx.Rollback()
  72. } else {
  73. tx.Commit()
  74. }
  75. So(err, ShouldBeNil)
  76. })
  77. }
  78. func TestDao_TxUpRound(t *testing.T) {
  79. var (
  80. c = context.Background()
  81. tx, _ = d.BeginTran(c)
  82. )
  83. Convey("TxUpRound", t, func(ctx C) {
  84. _, err := d.TxUpRound(tx, 2333, 0)
  85. if err != nil {
  86. tx.Rollback()
  87. } else {
  88. tx.Commit()
  89. }
  90. So(err, ShouldBeNil)
  91. })
  92. }
  93. func TestDao_TxUpAttr(t *testing.T) {
  94. var (
  95. c = context.Background()
  96. tx, _ = d.BeginTran(c)
  97. )
  98. Convey("TxUpAttr", t, func(ctx C) {
  99. _, err := d.TxUpAttr(tx, 2333, 0)
  100. if err != nil {
  101. tx.Rollback()
  102. } else {
  103. tx.Commit()
  104. }
  105. So(err, ShouldBeNil)
  106. })
  107. }
  108. func TestDao_TxUpCover(t *testing.T) {
  109. var (
  110. c = context.Background()
  111. tx, _ = d.BeginTran(c)
  112. )
  113. Convey("TxUpCover", t, func(ctx C) {
  114. _, err := d.TxUpCover(tx, 2333, "")
  115. if err != nil {
  116. tx.Rollback()
  117. } else {
  118. tx.Commit()
  119. }
  120. So(err, ShouldBeNil)
  121. })
  122. }
  123. func TestDao_UpCover(t *testing.T) {
  124. var (
  125. c = context.Background()
  126. )
  127. Convey("UpCover", t, func(ctx C) {
  128. _, err := d.UpCover(c, 2333, "")
  129. So(err, ShouldBeNil)
  130. })
  131. }
  132. func TestDao_TxUpArcDuration(t *testing.T) {
  133. var (
  134. c = context.Background()
  135. tx, _ = d.BeginTran(c)
  136. )
  137. Convey("TxUpArcDuration", t, func(ctx C) {
  138. _, err := d.TxUpArcDuration(tx, 2333, 0)
  139. if err != nil {
  140. tx.Rollback()
  141. } else {
  142. tx.Commit()
  143. }
  144. So(err, ShouldBeNil)
  145. })
  146. }
  147. func TestDao_TxUpAttrBit(t *testing.T) {
  148. var (
  149. c = context.Background()
  150. tx, _ = d.BeginTran(c)
  151. )
  152. Convey("TxUpAttrBit", t, func(ctx C) {
  153. _, err := d.TxUpAttrBit(tx, 2333, 0, 1)
  154. if err != nil {
  155. tx.Rollback()
  156. } else {
  157. tx.Commit()
  158. }
  159. So(err, ShouldBeNil)
  160. })
  161. }
  162. func TestDao_TxUpPTime(t *testing.T) {
  163. var (
  164. c = context.Background()
  165. tx, _ = d.BeginTran(c)
  166. tm time.Time
  167. )
  168. Convey("TxUpPTime", t, func(ctx C) {
  169. _, err := d.TxUpPTime(tx, 2333, tm)
  170. if err != nil {
  171. tx.Rollback()
  172. } else {
  173. tx.Commit()
  174. }
  175. So(err, ShouldBeNil)
  176. })
  177. }
  178. func Test_ArchiveAddict(t *testing.T) {
  179. var (
  180. c = context.TODO()
  181. err error
  182. sub *archive.Addit
  183. )
  184. Convey("Addit", t, WithDao(func(d *Dao) {
  185. sub, err = d.Addit(c, 23333)
  186. So(err, ShouldBeNil)
  187. So(sub, ShouldBeNil)
  188. }))
  189. }
  190. func Test_Delay(t *testing.T) {
  191. var (
  192. c = context.TODO()
  193. err error
  194. sub *archive.Delay
  195. )
  196. Convey("Delay", t, WithDao(func(d *Dao) {
  197. sub, err = d.Delay(c, 2333)
  198. So(err, ShouldBeNil)
  199. So(sub, ShouldBeNil)
  200. }))
  201. }
  202. func Test_NowDelays(t *testing.T) {
  203. var (
  204. c = context.TODO()
  205. err error
  206. sub []*archive.Delay
  207. )
  208. Convey("NowDelays", t, WithDao(func(d *Dao) {
  209. sub, err = d.NowDelays(c, time.Now())
  210. So(err, ShouldBeNil)
  211. So(sub, ShouldBeNil)
  212. }))
  213. }
  214. func Test_Forbid(t *testing.T) {
  215. var (
  216. c = context.TODO()
  217. err error
  218. sub *archive.ForbidAttr
  219. )
  220. Convey("Forbid", t, WithDao(func(d *Dao) {
  221. sub, err = d.Forbid(c, 23333)
  222. So(err, ShouldBeNil)
  223. So(sub, ShouldNotBeNil)
  224. }))
  225. }
  226. func Test_TrackPassed(t *testing.T) {
  227. var (
  228. c = context.TODO()
  229. err error
  230. sub int64
  231. )
  232. Convey("TrackPassed", t, WithDao(func(d *Dao) {
  233. sub, err = d.GetFirstPassByAID(c, 233)
  234. So(err, ShouldBeNil)
  235. So(sub, ShouldBeZeroValue)
  236. }))
  237. }
  238. func Test_TypeMapping(t *testing.T) {
  239. var (
  240. c = context.TODO()
  241. err error
  242. )
  243. Convey("TypeMapping", t, WithDao(func(d *Dao) {
  244. _, err = d.TypeMapping(c)
  245. So(err, ShouldBeNil)
  246. }))
  247. }
  248. /*func Test_AddRdsCovers(t *testing.T) {
  249. var (
  250. c = context.TODO()
  251. err error
  252. cvs = []*archive.Cover{
  253. &archive.Cover{
  254. Filename: "sssss",
  255. },
  256. }
  257. )
  258. Convey("AddRdsCovers", t, WithDao(func(d *Dao) {
  259. _, err = d.AddRdsCovers(c, cvs)
  260. So(err, ShouldBeNil)
  261. }))
  262. }*/
  263. func Test_DBus(t *testing.T) {
  264. var (
  265. c = context.TODO()
  266. err error
  267. )
  268. Convey("DBus", t, WithDao(func(d *Dao) {
  269. _, err = d.DBus(c, "sss", "sssew", 888)
  270. So(err, ShouldBeNil)
  271. }))
  272. }
  273. func Test_UpDBus(t *testing.T) {
  274. var (
  275. c = context.TODO()
  276. err error
  277. )
  278. Convey("UpDBus", t, WithDao(func(d *Dao) {
  279. _, err = d.UpDBus(c, "sss", "sssew", 888, 33)
  280. So(err, ShouldBeNil)
  281. }))
  282. }
  283. func Test_DelAdminDelay(t *testing.T) {
  284. var (
  285. c = context.TODO()
  286. err error
  287. )
  288. Convey("DelAdminDelay", t, WithDao(func(d *Dao) {
  289. _, err = d.DelAdminDelay(c, 2333)
  290. So(err, ShouldBeNil)
  291. }))
  292. }
  293. func Test_DelDelayByIds(t *testing.T) {
  294. var (
  295. c = context.TODO()
  296. err error
  297. )
  298. Convey("DelDelayByIds", t, WithDao(func(d *Dao) {
  299. _, err = d.DelDelayByIds(c, []int64{2333})
  300. So(err, ShouldBeNil)
  301. }))
  302. }
  303. func Test_FirstPassCount(t *testing.T) {
  304. var (
  305. c = context.TODO()
  306. err error
  307. )
  308. Convey("FirstPassCount", t, WithDao(func(d *Dao) {
  309. _, err = d.FirstPassCount(c, []int64{2333})
  310. So(err, ShouldBeNil)
  311. }))
  312. }
  313. func TestDao_TxUpForbid(t *testing.T) {
  314. var (
  315. c = context.Background()
  316. tx, _ = d.BeginTran(c)
  317. af = &archive.ForbidAttr{
  318. Aid: 2333,
  319. }
  320. )
  321. Convey("TxUpForbid", t, func(ctx C) {
  322. _, err := d.TxUpForbid(tx, af)
  323. if err != nil {
  324. tx.Rollback()
  325. } else {
  326. tx.Commit()
  327. }
  328. So(err, ShouldBeNil)
  329. })
  330. }
  331. func TestDao_TxUpVideoXState(t *testing.T) {
  332. var (
  333. c = context.Background()
  334. tx, _ = d.BeginTran(c)
  335. )
  336. Convey("TxUpVideoXState", t, func(ctx C) {
  337. _, err := d.TxUpVideoXState(tx, "sssss", 4)
  338. if err != nil {
  339. tx.Rollback()
  340. } else {
  341. tx.Commit()
  342. }
  343. So(err, ShouldBeNil)
  344. })
  345. }
  346. func TestDao_TxUpVideoPlayurl(t *testing.T) {
  347. var (
  348. c = context.Background()
  349. tx, _ = d.BeginTran(c)
  350. )
  351. Convey("TxUpVideoPlayurl", t, func(ctx C) {
  352. _, err := d.TxUpVideoPlayurl(tx, "sssss", "")
  353. if err != nil {
  354. tx.Rollback()
  355. } else {
  356. tx.Commit()
  357. }
  358. So(err, ShouldBeNil)
  359. })
  360. }
  361. func TestDao_TxUpVDuration(t *testing.T) {
  362. var (
  363. c = context.Background()
  364. tx, _ = d.BeginTran(c)
  365. )
  366. Convey("TxUpVDuration", t, func(ctx C) {
  367. _, err := d.TxUpVDuration(tx, "sssss", 4)
  368. if err != nil {
  369. tx.Rollback()
  370. } else {
  371. tx.Commit()
  372. }
  373. So(err, ShouldBeNil)
  374. })
  375. }
  376. func TestDao_TxUpVideoFilesize(t *testing.T) {
  377. var (
  378. c = context.Background()
  379. tx, _ = d.BeginTran(c)
  380. )
  381. Convey("TxUpVideoFilesize", t, func(ctx C) {
  382. _, err := d.TxUpVideoFilesize(tx, "sssss", 4)
  383. if err != nil {
  384. tx.Rollback()
  385. } else {
  386. tx.Commit()
  387. }
  388. So(err, ShouldBeNil)
  389. })
  390. }
  391. func TestDao_TxUpVideoResolutionsAndDimensions(t *testing.T) {
  392. var (
  393. c = context.Background()
  394. tx, _ = d.BeginTran(c)
  395. )
  396. Convey("TxUpVideoResolutionsAndDimensions", t, func(ctx C) {
  397. _, err := d.TxUpVideoResolutionsAndDimensions(tx, "sssss", "", "1280,720,0")
  398. if err != nil {
  399. tx.Rollback()
  400. } else {
  401. tx.Commit()
  402. }
  403. So(err, ShouldBeNil)
  404. })
  405. }
  406. func TestDao_TxUpVideoFailCode(t *testing.T) {
  407. var (
  408. c = context.Background()
  409. tx, _ = d.BeginTran(c)
  410. )
  411. Convey("TxUpVideoFailCode", t, func(ctx C) {
  412. _, err := d.TxUpVideoFailCode(tx, "sssss", -2)
  413. if err != nil {
  414. tx.Rollback()
  415. } else {
  416. tx.Commit()
  417. }
  418. So(err, ShouldBeNil)
  419. })
  420. }
  421. func TestDao_TxUpRelationStatus(t *testing.T) {
  422. var (
  423. c = context.Background()
  424. tx, _ = d.BeginTran(c)
  425. )
  426. Convey("TxUpRelationStatus", t, func(ctx C) {
  427. _, err := d.TxUpRelationStatus(tx, 2333, 0)
  428. if err != nil {
  429. tx.Rollback()
  430. } else {
  431. tx.Commit()
  432. }
  433. So(err, ShouldBeNil)
  434. })
  435. }
  436. func TestDao_NewVideos(t *testing.T) {
  437. var (
  438. c = context.Background()
  439. )
  440. Convey("NewVideos", t, func(ctx C) {
  441. _, err := d.NewVideos(c, 2333)
  442. So(err, ShouldBeNil)
  443. })
  444. }
  445. func TestDao_ValidAidByCid(t *testing.T) {
  446. var (
  447. c = context.Background()
  448. )
  449. Convey("ValidAidByCid", t, func(ctx C) {
  450. _, err := d.ValidAidByCid(c, 2333)
  451. So(err, ShouldBeNil)
  452. })
  453. }
  454. func TestDao_Stat(t *testing.T) {
  455. var (
  456. c = context.Background()
  457. )
  458. Convey("Stat", t, func(ctx C) {
  459. _, err := d.Stat(c, 2333)
  460. So(err, ShouldBeNil)
  461. })
  462. }
  463. func TestDao_TypeNaming(t *testing.T) {
  464. var (
  465. c = context.Background()
  466. )
  467. Convey("TypeNaming", t, func(ctx C) {
  468. _, err := d.TypeNaming(c)
  469. So(err, ShouldBeNil)
  470. })
  471. }
  472. func TestDao_VdoWithArcCntCapable(t *testing.T) {
  473. var (
  474. c = context.Background()
  475. )
  476. Convey("VdoWithArcCntCapable", t, func(ctx C) {
  477. _, err := d.VdoWithArcCntCapable(c, 2333)
  478. So(err, ShouldBeNil)
  479. })
  480. }
  481. func TestDao_VideoCountCapable(t *testing.T) {
  482. var (
  483. c = context.Background()
  484. )
  485. Convey("VideoCountCapable", t, func(ctx C) {
  486. _, err := d.VideoCountCapable(c, 2333)
  487. So(err, ShouldBeNil)
  488. })
  489. }
  490. func TestDao_Videos(t *testing.T) {
  491. var (
  492. c = context.Background()
  493. )
  494. Convey("Videos", t, func(ctx C) {
  495. _, err := d.Videos(c, 2333)
  496. So(err, ShouldBeNil)
  497. })
  498. }
  499. func TestDao_Video(t *testing.T) {
  500. var (
  501. c = context.Background()
  502. )
  503. Convey("Video", t, func(ctx C) {
  504. _, err := d.Video(c, "sssss")
  505. So(err, ShouldBeNil)
  506. })
  507. }
  508. func TestDao_TranVideoOper(t *testing.T) {
  509. var (
  510. c = context.Background()
  511. tx, _ = d.BeginTran(c)
  512. )
  513. Convey("TranVideoOper", t, func(ctx C) {
  514. guard := monkey.PatchInstanceMethod(reflect.TypeOf(tx), "Exec",
  515. func(_ *sql.Tx, _ string, _ ...interface{}) (xsql.Result, error) {
  516. return nil, fmt.Errorf("tx.Exec Error")
  517. })
  518. defer guard.Unpatch()
  519. _, err := d.TranVideoOper(c, tx, 2333, 111, 0, 0)
  520. if err != nil {
  521. tx.Rollback()
  522. } else {
  523. tx.Commit()
  524. }
  525. So(err, ShouldBeNil)
  526. })
  527. }
  528. /*func TestDao_AICover(t *testing.T) {
  529. var (
  530. c = context.Background()
  531. )
  532. Convey("AICover", t, func(ctx C) {
  533. _, err := d.AICover(c, "sssss")
  534. So(err, ShouldBeNil)
  535. })
  536. }*/