archive_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package archive
  2. import (
  3. "context"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/main/videoup/model/archive"
  6. "testing"
  7. )
  8. func TestArchive(t *testing.T) {
  9. Convey("test archive", t, WithDao(func(d *Dao) {
  10. aid := int64(10098814)
  11. a, err := d.Archive(context.Background(), aid)
  12. So(err, ShouldBeNil)
  13. So(a, ShouldNotBeNil)
  14. t.Logf("resp: %v", a)
  15. }))
  16. }
  17. func TestArchives(t *testing.T) {
  18. Convey("Archives", t, WithDao(func(d *Dao) {
  19. _, err := d.Archives(context.Background(), []int64{1, 2})
  20. So(err, ShouldBeNil)
  21. }))
  22. }
  23. func TestDao_TxUpArcNote(t *testing.T) {
  24. Convey("TxUpArcNote", t, WithDao(func(d *Dao) {
  25. var c = context.TODO()
  26. tx, _ := d.BeginTran(c)
  27. _, err := d.TxUpArcNote(tx, 111, "2")
  28. tx.Commit()
  29. So(err, ShouldBeNil)
  30. }))
  31. }
  32. func TestDao_TxUpArcMtime(t *testing.T) {
  33. Convey("TxUpArcMtime", t, WithDao(func(d *Dao) {
  34. var c = context.TODO()
  35. tx, _ := d.BeginTran(c)
  36. _, err := d.TxUpArcMtime(tx, 111)
  37. tx.Commit()
  38. So(err, ShouldBeNil)
  39. }))
  40. }
  41. func TestDao_TxUpArcAuthor(t *testing.T) {
  42. Convey("TxUpArcAuthor", t, WithDao(func(d *Dao) {
  43. var c = context.TODO()
  44. tx, _ := d.BeginTran(c)
  45. _, err := d.TxUpArcAuthor(tx, 111, 222, "222")
  46. tx.Commit()
  47. So(err, ShouldBeNil)
  48. }))
  49. }
  50. func TestDao_TxUpArcState(t *testing.T) {
  51. Convey("TxUpArcState", t, WithDao(func(d *Dao) {
  52. var c = context.TODO()
  53. tx, _ := d.BeginTran(c)
  54. _, err := d.TxUpArcState(tx, 111, 0)
  55. tx.Commit()
  56. So(err, ShouldBeNil)
  57. }))
  58. }
  59. func TestDao_TxUpArcAccess(t *testing.T) {
  60. Convey("TxUpArcAccess", t, WithDao(func(d *Dao) {
  61. var c = context.TODO()
  62. tx, _ := d.BeginTran(c)
  63. _, err := d.TxUpArcAccess(tx, 111, 0)
  64. tx.Commit()
  65. So(err, ShouldBeNil)
  66. }))
  67. }
  68. func TestDao_TxUpArcReason(t *testing.T) {
  69. Convey("TxUpArcReason", t, WithDao(func(d *Dao) {
  70. var c = context.TODO()
  71. tx, _ := d.BeginTran(c)
  72. _, err := d.TxUpArcReason(tx, 111, 0, "")
  73. tx.Commit()
  74. So(err, ShouldBeNil)
  75. }))
  76. }
  77. func TestDao_TxUpArcAttr(t *testing.T) {
  78. Convey("TxUpArcAttr", t, WithDao(func(d *Dao) {
  79. var c = context.TODO()
  80. tx, _ := d.BeginTran(c)
  81. _, err := d.TxUpArcAttr(tx, 111, 0, 1)
  82. tx.Commit()
  83. So(err, ShouldBeNil)
  84. }))
  85. }
  86. func TestDao_TxUpTag(t *testing.T) {
  87. Convey("TxUpTag", t, WithDao(func(d *Dao) {
  88. c := context.TODO()
  89. aid := int64(2880441)
  90. tx, _ := d.BeginTran(c)
  91. _, err := d.TxUpTag(tx, aid, "haha1,haha2,haha3")
  92. tx.Commit()
  93. So(err, ShouldBeNil)
  94. }))
  95. }
  96. func TestDao_TxUpInnerAttr(t *testing.T) {
  97. Convey("TxUpInnerAttr", t, WithDao(func(d *Dao) {
  98. c := context.TODO()
  99. addit := &archive.Addit{
  100. Aid: 3,
  101. }
  102. addit.InnerAttrSet(1, archive.InnerAttrChannelReview)
  103. tx, _ := d.BeginTran(c)
  104. _, err := d.TxUpInnerAttr(tx, addit.Aid, addit.InnerAttr)
  105. tx.Commit()
  106. So(err, ShouldBeNil)
  107. }))
  108. }
  109. func TestDao_TxUpArchive(t *testing.T) {
  110. Convey("TxUpArchive", t, WithDao(func(d *Dao) {
  111. c := context.TODO()
  112. tx, _ := d.BeginTran(c)
  113. a, err := d.Archive(c, 10098217)
  114. t.Logf("archive(%+v)", a)
  115. So(err, ShouldBeNil)
  116. if err == nil {
  117. _, err = d.TxUpArchive(tx, a.Aid, a.Title, "随便一个内容啦", a.Cover, "随意一个note", a.Copyright, a.PTime)
  118. So(err, ShouldBeNil)
  119. }
  120. tx.Commit()
  121. }))
  122. }
  123. func TestDao_TxUpArcTypeID(t *testing.T) {
  124. Convey("TxUpArcTypeID", t, WithDao(func(d *Dao) {
  125. c := context.TODO()
  126. tx, _ := d.BeginTran(c)
  127. _, err := d.TxUpArcTypeID(tx, 0, 0)
  128. So(err, ShouldBeNil)
  129. tx.Commit()
  130. }))
  131. }
  132. func TestDao_TxUpArcRound(t *testing.T) {
  133. Convey("TxUpArcRound", t, WithDao(func(d *Dao) {
  134. c := context.TODO()
  135. tx, _ := d.BeginTran(c)
  136. _, err := d.TxUpArcRound(tx, 0, 0)
  137. So(err, ShouldBeNil)
  138. tx.Commit()
  139. }))
  140. }
  141. func TestDao_TxUpArcPTime(t *testing.T) {
  142. Convey("TxUpArcPTime", t, WithDao(func(d *Dao) {
  143. c := context.TODO()
  144. tx, _ := d.BeginTran(c)
  145. _, err := d.TxUpArcPTime(tx, 0, 0)
  146. So(err, ShouldBeNil)
  147. tx.Commit()
  148. }))
  149. }
  150. func TestDao_TxUpArcCopyRight(t *testing.T) {
  151. Convey("TxUpArcCopyRight", t, WithDao(func(d *Dao) {
  152. c := context.TODO()
  153. tx, _ := d.BeginTran(c)
  154. _, err := d.TxUpArcCopyRight(tx, 0, 0)
  155. So(err, ShouldBeNil)
  156. tx.Commit()
  157. }))
  158. }
  159. func TestDao_ArcStateMap(t *testing.T) {
  160. Convey("ArcStateMap", t, WithDao(func(d *Dao) {
  161. c := context.TODO()
  162. _, err := d.ArcStateMap(c, []int64{1, 2, 3})
  163. So(err, ShouldBeNil)
  164. }))
  165. }