article_redis_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/web/model"
  6. artmdl "go-common/app/interface/openplatform/article/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaokeyArtList(t *testing.T) {
  10. convey.Convey("keyArtList", t, func(ctx convey.C) {
  11. var (
  12. rid = int64(0)
  13. sort = int(0)
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. p1 := keyArtList(rid, sort)
  17. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  18. ctx.So(p1, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoArticleListCache(t *testing.T) {
  24. convey.Convey("ArticleListCache", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. rid = int64(0)
  28. sort = int(0)
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. res, err := d.ArticleListCache(c, rid, sort)
  32. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. convey.Printf("%+v", res)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoSetArticleListCache(t *testing.T) {
  40. convey.Convey("SetArticleListCache", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. rid = int64(0)
  44. sort = int(0)
  45. list = []*artmdl.Meta{}
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. err := d.SetArticleListCache(c, rid, sort, list)
  49. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestDaoArticleUpListCache(t *testing.T) {
  56. convey.Convey("ArticleUpListCache", t, func(ctx convey.C) {
  57. var (
  58. c = context.Background()
  59. )
  60. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  61. res, err := d.ArticleUpListCache(c)
  62. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.Printf("%+v", res)
  65. })
  66. })
  67. })
  68. }
  69. func TestDaoSetArticleUpListCache(t *testing.T) {
  70. convey.Convey("SetArticleUpListCache", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. list = []*model.Info{}
  74. )
  75. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  76. err := d.SetArticleUpListCache(c, list)
  77. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  78. ctx.So(err, convey.ShouldBeNil)
  79. })
  80. })
  81. })
  82. }