video_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. "math/rand"
  8. "time"
  9. )
  10. func TestDao_TxAddVideo(t *testing.T) {
  11. var (
  12. c = context.Background()
  13. tx, _ = d.BeginTran(c)
  14. v = &archive.Video{
  15. ID: 123,
  16. Aid: 2333,
  17. Title: "UT测试",
  18. }
  19. )
  20. rand.Seed(time.Now().Unix())
  21. v.ID = int64(rand.Intn(999999999) + 1000000000)
  22. v.Aid = int64(rand.Intn(999999999) + 1000000000)
  23. Convey("TxAddVideo", t, func(ctx C) {
  24. _, err := d.TxAddVideo(tx, v)
  25. if err != nil {
  26. tx.Rollback()
  27. } else {
  28. tx.Commit()
  29. }
  30. So(err, ShouldBeNil)
  31. })
  32. }
  33. func TestDao_TxUpVideo(t *testing.T) {
  34. var (
  35. c = context.Background()
  36. tx, _ = d.BeginTran(c)
  37. v = &archive.Video{
  38. ID: 123,
  39. Aid: 2333,
  40. Title: "UT测试",
  41. }
  42. )
  43. Convey("TxUpVideo", t, func(ctx C) {
  44. _, err := d.TxUpVideo(tx, v)
  45. if err != nil {
  46. tx.Rollback()
  47. } else {
  48. tx.Commit()
  49. }
  50. So(err, ShouldBeNil)
  51. })
  52. }
  53. func TestDao_TxUpVideoStatus(t *testing.T) {
  54. var (
  55. c = context.Background()
  56. tx, _ = d.BeginTran(c)
  57. )
  58. Convey("TxUpVideoStatus", t, func(ctx C) {
  59. _, err := d.TxUpVideoStatus(tx, 2333, "sadasdadsds", 0)
  60. if err != nil {
  61. tx.Rollback()
  62. } else {
  63. tx.Commit()
  64. }
  65. So(err, ShouldBeNil)
  66. })
  67. }
  68. func TestDao_TxUpVideoXcode(t *testing.T) {
  69. var (
  70. c = context.Background()
  71. tx, _ = d.BeginTran(c)
  72. )
  73. Convey("TxUpVideoXcode", t, func(ctx C) {
  74. _, err := d.TxUpVideoXcode(tx, 2333, "sadasdadsds", 0)
  75. if err != nil {
  76. tx.Rollback()
  77. } else {
  78. tx.Commit()
  79. }
  80. So(err, ShouldBeNil)
  81. })
  82. }
  83. func TestDao_TxUpVideoAttr(t *testing.T) {
  84. var (
  85. c = context.Background()
  86. tx, _ = d.BeginTran(c)
  87. )
  88. Convey("TxUpVideoAttr", t, func(ctx C) {
  89. _, err := d.TxUpVideoAttr(tx, 2333, "sadasdadsds", 0)
  90. if err != nil {
  91. tx.Rollback()
  92. } else {
  93. tx.Commit()
  94. }
  95. So(err, ShouldBeNil)
  96. })
  97. }
  98. func TestDao_TxUpVideoCid(t *testing.T) {
  99. var (
  100. c = context.Background()
  101. tx, _ = d.BeginTran(c)
  102. )
  103. Convey("TxUpVideoCid", t, func(ctx C) {
  104. _, err := d.TxUpVideoCid(tx, 2333, "sadasdadsds", 1213)
  105. if err != nil {
  106. tx.Rollback()
  107. } else {
  108. tx.Commit()
  109. }
  110. So(err, ShouldBeNil)
  111. })
  112. }
  113. func TestDao_TxAddAudit(t *testing.T) {
  114. rand.Seed(time.Now().Unix())
  115. vid := int64(rand.Intn(999999) + 1000000000)
  116. var (
  117. c = context.Background()
  118. tx, _ = d.BeginTran(c)
  119. vs = []*archive.Video{{
  120. ID: vid,
  121. Aid: 2333,
  122. Title: "UT测试",
  123. }}
  124. )
  125. Convey("TxAddAudit", t, func(ctx C) {
  126. _, err := d.TxAddAudit(tx, vs)
  127. if err != nil {
  128. tx.Rollback()
  129. } else {
  130. tx.Commit()
  131. }
  132. So(err, ShouldBeNil)
  133. })
  134. }