sync_video_test.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package ugc
  2. import (
  3. "context"
  4. ugcmdl "go-common/app/job/main/tv/model/ugc"
  5. "testing"
  6. "fmt"
  7. "encoding/json"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestUgcPpVideos(t *testing.T) {
  11. var (
  12. c = context.Background()
  13. videos = []int64{}
  14. )
  15. convey.Convey("PpVideos", t, func(ctx convey.C) {
  16. err := d.PpVideos(c, videos)
  17. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. }
  22. func TestUgcFinishVideos(t *testing.T) {
  23. var (
  24. c = context.Background()
  25. videos = []*ugcmdl.SimpleVideo{}
  26. aid = int64(0)
  27. )
  28. convey.Convey("FinishVideos", t, func(ctx convey.C) {
  29. err := d.FinishVideos(c, videos, aid)
  30. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. })
  33. })
  34. }
  35. func TestDao_ParseArc(t *testing.T) {
  36. convey.Convey("TestDao_ParseArc", t, WithDao(func(d *Dao) {
  37. var (
  38. query = "SELECT aid FROM ugc_archive WHERE deleted = 0 LIMIT 1"
  39. arc = &ugcmdl.ArcCMS{}
  40. )
  41. d.DB.QueryRow(ctx, query).Scan(&arc.AID)
  42. res, err := d.ParseArc(ctx, int64(arc.AID))
  43. convey.So(err, convey.ShouldBeNil)
  44. convey.So(res, convey.ShouldNotBeNil)
  45. fmt.Println(res)
  46. }))
  47. }
  48. func TestDao_ParseVideos(t *testing.T) {
  49. convey.Convey("TestDao_ParseVideos", t, WithDao(func(d *Dao) {
  50. var (
  51. query = "SELECT aid FROM ugc_video WHERE deleted = 0 AND submit = 1 AND cid < 12780000 LIMIT 1"
  52. aid int64
  53. )
  54. if err := d.DB.QueryRow(ctx, query).Scan(&aid); err != nil {
  55. fmt.Println("No to submit data")
  56. return
  57. }
  58. fmt.Println(aid)
  59. res, err := d.ParseVideos(ctx, int64(aid), 2)
  60. convey.So(err, convey.ShouldBeNil)
  61. convey.So(len(res), convey.ShouldBeGreaterThan, 0)
  62. str, _ := json.Marshal(res)
  63. fmt.Println(string(str))
  64. for _, v := range res {
  65. convey.So(len(v), convey.ShouldBeGreaterThan, 0)
  66. }
  67. }))
  68. }
  69. func TestDao_ShouldAudit(t *testing.T) {
  70. convey.Convey("TestDao_ShouldAudit", t, WithDao(func(d *Dao) {
  71. var (
  72. query = "SELECT aid FROM ugc_video v WHERE v.submit = 1 " + _videoCond + " LIMIT 1"
  73. aid int64
  74. )
  75. fmt.Println(query)
  76. d.DB.QueryRow(ctx, fmt.Sprintf(query, d.criCID)).Scan(&aid)
  77. if aid == 0 {
  78. fmt.Println("db empty")
  79. return
  80. }
  81. res, err := d.ShouldAudit(ctx, aid)
  82. convey.So(err, convey.ShouldBeNil)
  83. convey.So(res, convey.ShouldBeTrue)
  84. fmt.Println(aid, " ", res)
  85. }))
  86. }
  87. func TestDao_VideoSubmit(t *testing.T) {
  88. convey.Convey("TestDao_VideoSubmit", t, WithDao(func(d *Dao) {
  89. var (
  90. query = "SELECT aid FROM ugc_video v WHERE v.submit = 0 " + _videoCond + " LIMIT 1"
  91. aid int64
  92. )
  93. fmt.Println(query)
  94. d.DB.QueryRow(ctx, fmt.Sprintf(query, d.criCID)).Scan(&aid)
  95. if aid == 0 {
  96. fmt.Println("db empty")
  97. return
  98. }
  99. res, err := d.VideoSubmit(ctx, aid)
  100. convey.So(err, convey.ShouldBeNil)
  101. convey.So(res, convey.ShouldNotBeNil)
  102. fmt.Println(aid, " ", res)
  103. }))
  104. }