ugc_single_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package cms
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/interface/main/tv/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestCmsArcMetaCache(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. aid = int64(0)
  13. )
  14. convey.Convey("ArcMetaCache", t, func(ctx convey.C) {
  15. ctx.Convey("Then err should be nil.s should not be nil.", func(ctx convey.C) {
  16. sids, err := pickIDs(d.db, _pickAids)
  17. if err != nil || len(sids) == 0 {
  18. fmt.Println("Empty Sids ", err)
  19. return
  20. }
  21. aid = sids[0]
  22. d.LoadArcMeta(c, aid)
  23. s, err := d.ArcMetaCache(c, aid)
  24. ctx.So(err, convey.ShouldBeNil)
  25. ctx.So(s, convey.ShouldNotBeNil)
  26. })
  27. ctx.Convey("mc not found Error", func(ctx convey.C) {
  28. _, err := d.ArcMetaCache(c, 0)
  29. ctx.So(err, convey.ShouldBeNil)
  30. })
  31. })
  32. }
  33. func TestCmsSetArcMetaCache(t *testing.T) {
  34. var (
  35. c = context.Background()
  36. s = &model.ArcCMS{}
  37. )
  38. convey.Convey("SetArcMetaCache", t, func(ctx convey.C) {
  39. err := d.SetArcMetaCache(c, s)
  40. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. })
  43. })
  44. }
  45. func TestCmsAddArcMetaCache(t *testing.T) {
  46. var (
  47. arc = &model.ArcCMS{}
  48. )
  49. convey.Convey("AddArcMetaCache", t, func(ctx convey.C) {
  50. d.AddArcMetaCache(arc)
  51. ctx.Convey("No return values", func(ctx convey.C) {
  52. })
  53. })
  54. }
  55. func TestCmsVideoMetaCache(t *testing.T) {
  56. var (
  57. c = context.Background()
  58. cid = int64(0)
  59. )
  60. convey.Convey("VideoMetaCache", t, func(ctx convey.C) {
  61. sids, err := pickIDs(d.db, _pickCids)
  62. if err != nil || len(sids) == 0 {
  63. fmt.Println("Empty Sids ", err)
  64. return
  65. }
  66. cid = sids[0]
  67. d.LoadVideoMeta(c, cid)
  68. s, err := d.VideoMetaCache(c, cid)
  69. ctx.Convey("Then err should be nil.s should not be nil.", func(ctx convey.C) {
  70. ctx.So(err, convey.ShouldBeNil)
  71. ctx.So(s, convey.ShouldNotBeNil)
  72. })
  73. })
  74. }
  75. func TestCmsSetVideoMetaCache(t *testing.T) {
  76. var (
  77. c = context.Background()
  78. s = &model.VideoCMS{}
  79. )
  80. convey.Convey("SetVideoMetaCache", t, func(ctx convey.C) {
  81. err := d.SetVideoMetaCache(c, s)
  82. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  83. ctx.So(err, convey.ShouldBeNil)
  84. })
  85. })
  86. }
  87. func TestCmsAddVideoMetaCache(t *testing.T) {
  88. var (
  89. video = &model.VideoCMS{}
  90. )
  91. convey.Convey("AddVideoMetaCache", t, func(ctx convey.C) {
  92. d.AddVideoMetaCache(video)
  93. ctx.Convey("No return values", func(ctx convey.C) {
  94. })
  95. })
  96. }