ugc_batch_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package cms
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestCmsArcCMSCacheKey(t *testing.T) {
  9. var (
  10. aid = int64(0)
  11. )
  12. convey.Convey("ArcCMSCacheKey", t, func(c convey.C) {
  13. p1 := d.ArcCMSCacheKey(aid)
  14. c.Convey("Then p1 should not be nil.", func(c convey.C) {
  15. c.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestCmsVideoCMSCacheKey(t *testing.T) {
  20. var (
  21. cid = int64(0)
  22. )
  23. convey.Convey("VideoCMSCacheKey", t, func(c convey.C) {
  24. p1 := d.VideoCMSCacheKey(cid)
  25. c.Convey("Then p1 should not be nil.", func(c convey.C) {
  26. c.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestCmsArcsMetaCache(t *testing.T) {
  31. var (
  32. ctx = context.Background()
  33. )
  34. convey.Convey("ArcsMetaCache", t, func(c convey.C) {
  35. sids, errPick := pickIDs(d.db, _pickAids)
  36. if errPick != nil || len(sids) == 0 {
  37. fmt.Println("Empty sids ", errPick)
  38. return
  39. }
  40. cached, missed, err := d.ArcsMetaCache(ctx, sids)
  41. c.Convey("Then err should be nil.cached,missed should not be nil.", func(c convey.C) {
  42. c.So(err, convey.ShouldBeNil)
  43. c.So(len(missed)+len(cached), convey.ShouldEqual, len(sids))
  44. })
  45. })
  46. }
  47. func TestCmsVideosMetaCache(t *testing.T) {
  48. var (
  49. ctx = context.Background()
  50. )
  51. convey.Convey("VideosMetaCache", t, func(c convey.C) {
  52. sids, errPick := pickIDs(d.db, _pickCids)
  53. if errPick != nil || len(sids) == 0 {
  54. fmt.Println("Empty sids ", errPick)
  55. return
  56. }
  57. cached, missed, err := d.VideosMetaCache(ctx, sids)
  58. c.Convey("Then err should be nil.cached,missed should not be nil.", func(c convey.C) {
  59. c.So(err, convey.ShouldBeNil)
  60. c.So(len(missed)+len(cached), convey.ShouldEqual, len(sids))
  61. })
  62. })
  63. }