redis_test.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/playlist/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaokeyPlArc(t *testing.T) {
  9. var (
  10. pid = int64(1)
  11. )
  12. convey.Convey("keyPlArc", t, func(ctx convey.C) {
  13. p1 := keyPlArc(pid)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaokeyPlArcDesc(t *testing.T) {
  20. var (
  21. pid = int64(1)
  22. )
  23. convey.Convey("keyPlArcDesc", t, func(ctx convey.C) {
  24. p1 := keyPlArcDesc(pid)
  25. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  26. ctx.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestDaoArcsCache(t *testing.T) {
  31. var (
  32. c = context.Background()
  33. pid = int64(1)
  34. start = int(1)
  35. end = int(20)
  36. )
  37. convey.Convey("ArcsCache", t, func(ctx convey.C) {
  38. _, err := d.ArcsCache(c, pid, start, end)
  39. ctx.Convey("Then err should be nil.arcs should not be nil.", func(ctx convey.C) {
  40. ctx.So(err, convey.ShouldBeNil)
  41. })
  42. })
  43. }
  44. func TestDaoAddArcCache(t *testing.T) {
  45. var (
  46. c = context.Background()
  47. pid = int64(1)
  48. arc = &model.ArcSort{Aid: 13825646, Sort: 100, Desc: "abc"}
  49. )
  50. convey.Convey("AddArcCache", t, func(ctx convey.C) {
  51. err := d.AddArcCache(c, pid, arc)
  52. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  53. ctx.So(err, convey.ShouldBeNil)
  54. })
  55. })
  56. }
  57. func TestDaoSetArcsCache(t *testing.T) {
  58. var (
  59. c = context.Background()
  60. pid = int64(1)
  61. arcs = []*model.ArcSort{}
  62. )
  63. convey.Convey("SetArcsCache", t, func(ctx convey.C) {
  64. arcs = append(arcs, &model.ArcSort{Aid: 13825646, Sort: 100, Desc: "abc"})
  65. err := d.SetArcsCache(c, pid, arcs)
  66. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  67. ctx.So(err, convey.ShouldBeNil)
  68. })
  69. })
  70. }
  71. func TestDaoSetArcDescCache(t *testing.T) {
  72. var (
  73. c = context.Background()
  74. pid = int64(1)
  75. aid = int64(13825646)
  76. desc = "abc"
  77. )
  78. convey.Convey("SetArcDescCache", t, func(ctx convey.C) {
  79. err := d.SetArcDescCache(c, pid, aid, desc)
  80. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. })
  83. })
  84. }
  85. func TestDaoDelArcsCache(t *testing.T) {
  86. var (
  87. c = context.Background()
  88. pid = int64(1)
  89. aids = []int64{13825646, 11, 100}
  90. )
  91. convey.Convey("DelArcsCache", t, func(ctx convey.C) {
  92. err := d.DelArcsCache(c, pid, aids)
  93. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  94. ctx.So(err, convey.ShouldBeNil)
  95. })
  96. })
  97. }
  98. func TestDaoDelCache(t *testing.T) {
  99. var (
  100. c = context.Background()
  101. pid = int64(1)
  102. )
  103. convey.Convey("DelCache", t, func(ctx convey.C) {
  104. err := d.DelCache(c, pid)
  105. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  106. ctx.So(err, convey.ShouldBeNil)
  107. })
  108. })
  109. }