redis_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package video
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/favorite/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestVideocoversKey(t *testing.T) {
  9. convey.Convey("coversKey", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(1)
  12. fid = int64(1)
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. p1 := coversKey(mid, fid)
  16. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  17. ctx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func Test_pingRedis(t *testing.T) {
  23. convey.Convey("pingRedis", t, func(ctx convey.C) {
  24. var c = context.Background()
  25. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  26. err := d.pingRedis(c)
  27. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  28. ctx.So(err, convey.ShouldBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestVideoSetNewCoverCache(t *testing.T) {
  34. convey.Convey("SetNewCoverCache", t, func(ctx convey.C) {
  35. var (
  36. c = context.Background()
  37. mid = int64(1)
  38. fid = int64(1)
  39. covers = []*model.Cover{{
  40. Aid: 123,
  41. Pic: "123",
  42. Type: 2,
  43. },
  44. }
  45. )
  46. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  47. err := d.SetNewCoverCache(c, mid, fid, covers)
  48. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. })
  51. })
  52. })
  53. }
  54. func TestVideoNewCoversCache(t *testing.T) {
  55. convey.Convey("NewCoversCache", t, func(ctx convey.C) {
  56. var (
  57. c = context.Background()
  58. mid = int64(1)
  59. fids = []int64{1}
  60. )
  61. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  62. _, _, err := d.NewCoversCache(c, mid, fids)
  63. ctx.Convey("Then err should be nil.fcvs,mis should not be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. })
  66. })
  67. })
  68. }
  69. func TestDelCoverCache(t *testing.T) {
  70. convey.Convey("DelCoverCache", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. mid = int64(1)
  74. fid = int64(1)
  75. )
  76. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  77. err := d.DelCoverCache(c, mid, fid)
  78. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. })
  81. })
  82. })
  83. }