mysql_subtitle_test.go 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/dm2/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 TestDaoAddSubtitleSubject(t *testing.T) {
  22. convey.Convey("AddSubtitleSubject", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. subtitleSubject = &model.SubtitleSubject{}
  26. )
  27. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  28. err := testDao.AddSubtitleSubject(c, subtitleSubject)
  29. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaoGetSubtitleSubject(t *testing.T) {
  36. convey.Convey("GetSubtitleSubject", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. aid = int64(0)
  40. )
  41. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  42. subtitleSubject, err := testDao.GetSubtitleSubject(c, aid)
  43. ctx.Convey("Then err should be nil.subtitleSubject should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. ctx.So(subtitleSubject, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoGetSubtitleIds(t *testing.T) {
  51. convey.Convey("GetSubtitleIds", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. oid = int64(0)
  55. tp = int32(0)
  56. )
  57. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  58. subtitlIds, err := testDao.GetSubtitleIds(c, oid, tp)
  59. ctx.Convey("Then err should be nil.subtitlIds should not be nil.", func(ctx convey.C) {
  60. ctx.So(err, convey.ShouldBeNil)
  61. ctx.So(subtitlIds, convey.ShouldNotBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoGetSubtitles(t *testing.T) {
  67. convey.Convey("GetSubtitles", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. oid = int64(0)
  71. subtitleIds = []int64{}
  72. )
  73. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  74. testDao.GetSubtitles(c, oid, subtitleIds)
  75. })
  76. })
  77. }
  78. func TestDaoGetSubtitleDraft(t *testing.T) {
  79. convey.Convey("GetSubtitleDraft", t, func(ctx convey.C) {
  80. var (
  81. c = context.Background()
  82. oid = int64(0)
  83. tp = int32(0)
  84. mid = int64(0)
  85. lan = uint8(0)
  86. )
  87. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  88. subtitle, err := testDao.GetSubtitleDraft(c, oid, tp, mid, lan)
  89. ctx.Convey("Then err should be nil.subtitle should not be nil.", func(ctx convey.C) {
  90. ctx.So(err, convey.ShouldBeNil)
  91. ctx.So(subtitle, convey.ShouldNotBeNil)
  92. })
  93. })
  94. })
  95. }
  96. func TestDaoGetSubtitle(t *testing.T) {
  97. convey.Convey("GetSubtitle", t, func(ctx convey.C) {
  98. var (
  99. c = context.Background()
  100. oid = int64(0)
  101. subtitleID = int64(0)
  102. )
  103. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  104. testDao.GetSubtitle(c, oid, subtitleID)
  105. })
  106. })
  107. }
  108. func TestDaoAddSubtitle(t *testing.T) {
  109. convey.Convey("AddSubtitle", t, func(ctx convey.C) {
  110. var (
  111. c = context.Background()
  112. subtitle = &model.Subtitle{}
  113. )
  114. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  115. testDao.AddSubtitle(c, subtitle)
  116. })
  117. })
  118. }
  119. func TestDaoUpdateSubtitle(t *testing.T) {
  120. convey.Convey("UpdateSubtitle", t, func(ctx convey.C) {
  121. var (
  122. c = context.Background()
  123. subtitle = &model.Subtitle{}
  124. )
  125. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  126. err := testDao.UpdateSubtitle(c, subtitle)
  127. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  128. ctx.So(err, convey.ShouldBeNil)
  129. })
  130. })
  131. })
  132. }
  133. func TestDaoTxUpdateSubtitle(t *testing.T) {
  134. convey.Convey("TxUpdateSubtitle", t, func(ctx convey.C) {
  135. var (
  136. tx, _ = testDao.BeginBiliDMTrans(c)
  137. subtitle = &model.Subtitle{}
  138. )
  139. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  140. err := testDao.TxUpdateSubtitle(tx, subtitle)
  141. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  142. ctx.So(err, convey.ShouldBeNil)
  143. })
  144. })
  145. ctx.Reset(func() {
  146. tx.Commit()
  147. })
  148. })
  149. }
  150. func TestDaoTxAddSubtitlePub(t *testing.T) {
  151. convey.Convey("TxAddSubtitlePub", t, func(ctx convey.C) {
  152. var (
  153. c = context.Background()
  154. tx, _ = testDao.BeginBiliDMTrans(c)
  155. subtitlePub = &model.SubtitlePub{}
  156. )
  157. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  158. err := testDao.TxAddSubtitlePub(tx, subtitlePub)
  159. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  160. ctx.So(err, convey.ShouldBeNil)
  161. })
  162. })
  163. ctx.Reset(func() {
  164. tx.Commit()
  165. })
  166. })
  167. }
  168. func TestDaoTxGetSubtitleOne(t *testing.T) {
  169. convey.Convey("TxGetSubtitleOne", t, func(ctx convey.C) {
  170. var (
  171. c = context.Background()
  172. tx, _ = testDao.BeginBiliDMTrans(c)
  173. oid = int64(0)
  174. tp = int32(0)
  175. lan = uint8(0)
  176. )
  177. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  178. testDao.TxGetSubtitleOne(tx, oid, tp, lan)
  179. })
  180. ctx.Reset(func() {
  181. tx.Commit()
  182. })
  183. })
  184. }
  185. func TestDaoSubtitleLans(t *testing.T) {
  186. convey.Convey("SubtitleLans", t, func(ctx convey.C) {
  187. var (
  188. c = context.Background()
  189. )
  190. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  191. subtitleLans, err := testDao.SubtitleLans(c)
  192. ctx.Convey("Then err should be nil.subtitleLans should not be nil.", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. ctx.So(subtitleLans, convey.ShouldNotBeNil)
  195. })
  196. })
  197. })
  198. }
  199. func TestDaoSubtitleLanAdd(t *testing.T) {
  200. convey.Convey("SubtitleLanAdd", t, func(ctx convey.C) {
  201. var (
  202. c = context.Background()
  203. subtitleLan = &model.SubtitleLan{}
  204. )
  205. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  206. err := testDao.SubtitleLanAdd(c, subtitleLan)
  207. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  208. ctx.So(err, convey.ShouldBeNil)
  209. })
  210. })
  211. })
  212. }
  213. func TestDaoUpsertWaveFrom(t *testing.T) {
  214. convey.Convey("UpsertWaveFrom", t, func(ctx convey.C) {
  215. var (
  216. c = context.Background()
  217. waveForm = &model.WaveForm{}
  218. )
  219. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  220. err := testDao.UpsertWaveFrom(c, waveForm)
  221. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  222. ctx.So(err, convey.ShouldBeNil)
  223. })
  224. })
  225. })
  226. }
  227. func TestDaoGetWaveForm(t *testing.T) {
  228. convey.Convey("GetWaveForm", t, func(ctx convey.C) {
  229. var (
  230. c = context.Background()
  231. oid = int64(0)
  232. tp = int32(0)
  233. )
  234. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  235. waveForm, err := testDao.GetWaveForm(c, oid, tp)
  236. ctx.Convey("Then err should be nil.waveForm should not be nil.", func(ctx convey.C) {
  237. ctx.So(err, convey.ShouldBeNil)
  238. ctx.So(waveForm, convey.ShouldNotBeNil)
  239. })
  240. })
  241. })
  242. }