mysql_subtitle_test.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/dm/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaohitSubtitle(t *testing.T) {
  9. convey.Convey("hitSubtitle", t, func(ctx convey.C) {
  10. var (
  11. oid = int64(0)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. p1 := testDao.hitSubtitle(oid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoGetSubtitles(t *testing.T) {
  22. convey.Convey("GetSubtitles", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. oid = int64(0)
  26. subtitleIds = []int64{}
  27. )
  28. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  29. testDao.GetSubtitles(c, oid, subtitleIds)
  30. })
  31. })
  32. }
  33. func TestDaoGetSubtitle(t *testing.T) {
  34. convey.Convey("GetSubtitle", t, func(ctx convey.C) {
  35. var (
  36. c = context.Background()
  37. oid = int64(0)
  38. subtitleID = int64(0)
  39. )
  40. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  41. testDao.GetSubtitle(c, oid, subtitleID)
  42. })
  43. })
  44. }
  45. func TestDaoUpdateSubtitle(t *testing.T) {
  46. convey.Convey("UpdateSubtitle", t, func(ctx convey.C) {
  47. var (
  48. c = context.Background()
  49. subtitle = &model.Subtitle{}
  50. )
  51. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  52. err := testDao.UpdateSubtitle(c, subtitle)
  53. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestDaoCountSubtitleDraft(t *testing.T) {
  60. convey.Convey("CountSubtitleDraft", t, func(ctx convey.C) {
  61. var (
  62. c = context.Background()
  63. oid = int64(0)
  64. mid = int64(0)
  65. lan = uint8(0)
  66. tp = int32(0)
  67. )
  68. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  69. count, err := testDao.CountSubtitleDraft(c, oid, mid, lan, tp)
  70. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. ctx.So(count, convey.ShouldNotBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoTxUpdateSubtitle(t *testing.T) {
  78. convey.Convey("TxUpdateSubtitle", t, func(ctx convey.C) {
  79. var (
  80. tx, _ = testDao.BeginBiliDMTrans(context.TODO())
  81. subtitle = &model.Subtitle{}
  82. )
  83. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  84. testDao.TxUpdateSubtitle(tx, subtitle)
  85. })
  86. ctx.Reset(func() {
  87. tx.Commit()
  88. })
  89. })
  90. }
  91. func TestDaoTxGetSubtitleID(t *testing.T) {
  92. convey.Convey("TxGetSubtitleID", t, func(ctx convey.C) {
  93. var (
  94. tx, _ = testDao.BeginBiliDMTrans(context.TODO())
  95. oid = int64(0)
  96. tp = int32(0)
  97. lan = uint8(0)
  98. )
  99. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  100. testDao.TxGetSubtitleID(tx, oid, tp, lan)
  101. })
  102. ctx.Reset(func() {
  103. tx.Commit()
  104. })
  105. })
  106. }
  107. func TestDaoTxUpdateSubtitlePub(t *testing.T) {
  108. convey.Convey("TxUpdateSubtitlePub", t, func(ctx convey.C) {
  109. var (
  110. tx, _ = testDao.BeginBiliDMTrans(context.TODO())
  111. subtitlePub = &model.SubtitlePub{}
  112. )
  113. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  114. testDao.TxUpdateSubtitlePub(tx, subtitlePub)
  115. })
  116. ctx.Reset(func() {
  117. tx.Commit()
  118. })
  119. })
  120. }
  121. func TestDaoSubtitleLans(t *testing.T) {
  122. convey.Convey("SubtitleLans", t, func(ctx convey.C) {
  123. var (
  124. c = context.Background()
  125. )
  126. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  127. subtitleLans, err := testDao.SubtitleLans(c)
  128. ctx.Convey("Then err should be nil.subtitleLans should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(subtitleLans, convey.ShouldNotBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestDaoAddSubtitleSubject(t *testing.T) {
  136. convey.Convey("AddSubtitleSubject", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. subtitleSubject = &model.SubtitleSubject{}
  140. )
  141. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  142. err := testDao.AddSubtitleSubject(c, subtitleSubject)
  143. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  144. ctx.So(err, convey.ShouldBeNil)
  145. })
  146. })
  147. })
  148. }
  149. func TestDaoGetSubtitleSubject(t *testing.T) {
  150. convey.Convey("GetSubtitleSubject", t, func(ctx convey.C) {
  151. var (
  152. c = context.Background()
  153. aid = int64(0)
  154. )
  155. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  156. subtitleSubject, err := testDao.GetSubtitleSubject(c, aid)
  157. ctx.Convey("Then err should be nil.subtitleSubject should not be nil.", func(ctx convey.C) {
  158. ctx.So(err, convey.ShouldBeNil)
  159. ctx.So(subtitleSubject, convey.ShouldNotBeNil)
  160. })
  161. })
  162. })
  163. }