history_test.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package archive
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. "go-common/app/service/main/videoup/model/archive"
  8. )
  9. func TestDao_TxAddArcHistory(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. tx, _ = d.BeginTran(c)
  13. )
  14. Convey("TxAddArcHistory", t, func(ctx C) {
  15. _, err := d.TxAddArcHistory(tx, 23333, 123, "ssss", "content", "", "")
  16. if err != nil {
  17. tx.Rollback()
  18. } else {
  19. tx.Commit()
  20. }
  21. So(err, ShouldBeNil)
  22. })
  23. }
  24. func TestDao_TxAddVideoHistory(t *testing.T) {
  25. var (
  26. c = context.Background()
  27. tx, _ = d.BeginTran(c)
  28. v = &archive.Video{
  29. Aid: 23333,
  30. Cid: 12121,
  31. Title: "sssss",
  32. }
  33. )
  34. Convey("TxAddVideoHistory", t, func(ctx C) {
  35. _, err := d.TxAddVideoHistory(tx, 23333, v)
  36. if err != nil {
  37. tx.Rollback()
  38. } else {
  39. tx.Commit()
  40. }
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. func TestDao_TxUpVideoHistory(t *testing.T) {
  45. var (
  46. c = context.Background()
  47. tx, _ = d.BeginTran(c)
  48. )
  49. Convey("TxUpVideoHistory", t, func(ctx C) {
  50. _, err := d.TxUpVideoHistory(tx, 23333, 1212, "")
  51. if err != nil {
  52. tx.Rollback()
  53. } else {
  54. tx.Commit()
  55. }
  56. So(err, ShouldBeNil)
  57. })
  58. }
  59. func TestDao_TxAddVideoHistorys(t *testing.T) {
  60. var (
  61. c = context.Background()
  62. tx, _ = d.BeginTran(c)
  63. vs = []*archive.Video{{
  64. Aid: 23333,
  65. Cid: 12121,
  66. Title: "sssss",
  67. }}
  68. )
  69. Convey("TxAddVideoHistorys", t, func(ctx C) {
  70. err := d.TxAddVideoHistorys(tx, 23333, vs)
  71. if err != nil {
  72. tx.Rollback()
  73. } else {
  74. tx.Commit()
  75. }
  76. So(err, ShouldBeNil)
  77. })
  78. }
  79. func TestArchiveArcHistory(t *testing.T) {
  80. var (
  81. c = context.Background()
  82. hid = int64(23333)
  83. )
  84. Convey("ArcHistory", t, func(ctx C) {
  85. _, err := d.ArcHistory(c, hid)
  86. ctx.Convey("Then err should be nil.ah should not be nil.", func(ctx C) {
  87. ctx.So(err, ShouldBeNil)
  88. })
  89. })
  90. }
  91. func TestArchiveArcHistorys(t *testing.T) {
  92. var (
  93. c = context.Background()
  94. aid = int64(23333)
  95. stime = time.Now()
  96. )
  97. Convey("ArcHistorys", t, func(ctx C) {
  98. _, err := d.ArcHistorys(c, aid, stime)
  99. ctx.Convey("Then err should be nil.ahs should not be nil.", func(ctx C) {
  100. ctx.So(err, ShouldBeNil)
  101. })
  102. })
  103. }
  104. func TestArchiveVideoHistory(t *testing.T) {
  105. var (
  106. c = context.Background()
  107. hid = int64(23333)
  108. )
  109. Convey("VideoHistory", t, func(ctx C) {
  110. _, err := d.VideoHistory(c, hid)
  111. ctx.Convey("Then err should be nil.vhs should not be nil.", func(ctx C) {
  112. ctx.So(err, ShouldBeNil)
  113. })
  114. })
  115. }