extension_test.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/bbq/topic/api"
  5. "go-common/app/service/bbq/topic/internal/model"
  6. "go-common/library/log"
  7. "testing"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoRawVideoExtension(t *testing.T) {
  11. convey.Convey("RawVideoExtension", t, func(convCtx convey.C) {
  12. var (
  13. ctx = context.Background()
  14. svids = []int64{1}
  15. )
  16. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  17. res, err := d.RawVideoExtension(ctx, svids)
  18. log.V(1).Infow(ctx, "res", res)
  19. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  20. convCtx.So(err, convey.ShouldBeNil)
  21. convCtx.So(res, convey.ShouldNotBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoCacheVideoExtension(t *testing.T) {
  27. convey.Convey("CacheVideoExtension", t, func(convCtx convey.C) {
  28. var (
  29. ctx = context.Background()
  30. svids = []int64{1}
  31. )
  32. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  33. res, err := d.CacheVideoExtension(ctx, svids)
  34. log.V(1).Infow(ctx, "res", res)
  35. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  36. convCtx.So(err, convey.ShouldBeNil)
  37. convCtx.So(res, convey.ShouldNotBeNil)
  38. })
  39. })
  40. })
  41. }
  42. func TestDaoAddCacheVideoExtension(t *testing.T) {
  43. convey.Convey("AddCacheVideoExtension", t, func(convCtx convey.C) {
  44. var (
  45. ctx = context.Background()
  46. )
  47. extensions := make(map[int64]*api.VideoExtension)
  48. extensions[1] = &api.VideoExtension{Svid: 1, Extension: "{\"title_extra\":[{\"type\":1,\"name\":\"Test\",\"end\":4,\"schema\":\"qing://topic?topic_id=1\"}]}"}
  49. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  50. err := d.AddCacheVideoExtension(ctx, extensions)
  51. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  52. convCtx.So(err, convey.ShouldBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestDaoDelCacheVideoExtension(t *testing.T) {
  58. convey.Convey("DelCacheVideoExtension", t, func(convCtx convey.C) {
  59. var (
  60. ctx = context.Background()
  61. svid = int64(1)
  62. )
  63. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  64. d.DelCacheVideoExtension(ctx, svid)
  65. convCtx.Convey("No return values", func(convCtx convey.C) {
  66. })
  67. })
  68. })
  69. }
  70. func TestDaoInsertExtension(t *testing.T) {
  71. convey.Convey("InsertExtension", t, func(convCtx convey.C) {
  72. var (
  73. ctx = context.Background()
  74. svid = int64(1)
  75. extensionType = int64(1)
  76. extension = &api.Extension{TitleExtra: []*api.TitleExtraItem{{Name: "Test", Type: model.TitleExtraTypeTopic, Start: 0, End: 4, Scheme: "qing://topic?topic_id=1"}}}
  77. )
  78. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  79. rowsAffected, err := d.InsertExtension(ctx, svid, extensionType, extension)
  80. convCtx.Convey("Then err should be nil.rowsAffected should not be nil.", func(convCtx convey.C) {
  81. convCtx.So(err, convey.ShouldBeNil)
  82. convCtx.So(rowsAffected, convey.ShouldNotBeNil)
  83. })
  84. })
  85. })
  86. }