ugc_load_test.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package cms
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestCmsLoadArcsMediaMap(t *testing.T) {
  9. var ctx = context.Background()
  10. convey.Convey("LoadArcsMediaMap", t, func(c convey.C) {
  11. aids, errPick := pickIDs(d.db, _pickAids)
  12. if errPick != nil || len(aids) == 0 {
  13. fmt.Println("Empty aids ", errPick)
  14. return
  15. }
  16. resMetas, err := d.LoadArcsMediaMap(ctx, aids)
  17. c.Convey("Then err should be nil.resMetas should not be nil.", func(c convey.C) {
  18. c.So(err, convey.ShouldBeNil)
  19. c.So(resMetas, convey.ShouldNotBeNil)
  20. })
  21. })
  22. }
  23. func TestCmsLoadVideosMeta(t *testing.T) {
  24. var (
  25. ctx = context.Background()
  26. cids = []int64{}
  27. )
  28. convey.Convey("LoadVideosMeta", t, func(c convey.C) {
  29. resMetas, err := d.LoadVideosMeta(ctx, cids)
  30. c.Convey("Then err should be nil.resMetas should not be nil.", func(c convey.C) {
  31. c.So(err, convey.ShouldBeNil)
  32. c.So(resMetas, convey.ShouldNotBeNil)
  33. })
  34. })
  35. }
  36. func TestCmsLoadArcsMedia(t *testing.T) {
  37. var (
  38. ctx = context.Background()
  39. )
  40. convey.Convey("LoadArcsMedia", t, func(c convey.C) {
  41. aids, errPick := pickIDs(d.db, _pickAids)
  42. if errPick != nil || len(aids) == 0 {
  43. fmt.Println("Empty aids ", errPick)
  44. return
  45. }
  46. arcs, err := d.LoadArcsMedia(ctx, aids)
  47. c.Convey("Then err should be nil.arcs should not be nil.", func(c convey.C) {
  48. c.So(err, convey.ShouldBeNil)
  49. c.So(arcs, convey.ShouldNotBeNil)
  50. })
  51. })
  52. }
  53. func TestCmsLoadArcMeta(t *testing.T) {
  54. var (
  55. ctx = context.Background()
  56. aid = int64(0)
  57. )
  58. convey.Convey("LoadArcMeta", t, func(c convey.C) {
  59. aids, errPick := pickIDs(d.db, _pickAids)
  60. if errPick != nil || len(aids) == 0 {
  61. fmt.Println("Empty aids ", errPick)
  62. return
  63. }
  64. aid = aids[0]
  65. arcMeta, err := d.LoadArcMeta(ctx, aid)
  66. c.Convey("Then err should be nil.arcMeta should not be nil.", func(c convey.C) {
  67. c.So(err, convey.ShouldBeNil)
  68. c.So(arcMeta, convey.ShouldNotBeNil)
  69. })
  70. })
  71. }
  72. func TestCmsLoadVideoMeta(t *testing.T) {
  73. var (
  74. ctx = context.Background()
  75. cid = int64(0)
  76. )
  77. convey.Convey("LoadVideoMeta", t, func(c convey.C) {
  78. aids, errPick := pickIDs(d.db, _pickCids)
  79. if errPick != nil || len(aids) == 0 {
  80. fmt.Println("Empty aids ", errPick)
  81. return
  82. }
  83. cid = aids[0]
  84. videoMeta, err := d.LoadVideoMeta(ctx, cid)
  85. c.Convey("Then err should be nil.videoMeta should not be nil.", func(c convey.C) {
  86. c.So(err, convey.ShouldBeNil)
  87. c.So(videoMeta, convey.ShouldNotBeNil)
  88. })
  89. })
  90. }