newlist_redis_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. xtime "time"
  6. "go-common/app/service/main/archive/api"
  7. "go-common/library/time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaokeyNl(t *testing.T) {
  11. convey.Convey("keyNl", t, func(ctx convey.C) {
  12. var (
  13. rid = int32(0)
  14. tp = int8(0)
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. p1 := keyNl(rid, tp)
  18. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  19. ctx.So(p1, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaokeyNlBak(t *testing.T) {
  25. convey.Convey("keyNlBak", t, func(ctx convey.C) {
  26. var (
  27. rid = int32(0)
  28. tp = int8(0)
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. p1 := keyNlBak(rid, tp)
  32. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  33. ctx.So(p1, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestDaoNewListCache(t *testing.T) {
  39. convey.Convey("NewListCache", t, func(ctx convey.C) {
  40. var (
  41. c = context.Background()
  42. rid = int32(0)
  43. tp = int8(0)
  44. start = int(0)
  45. end = int(0)
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. arcs, count, err := d.NewListCache(c, rid, tp, start, end)
  49. ctx.Convey("Then err should be nil.arcs,count should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(count, convey.ShouldNotBeNil)
  52. ctx.Printf("%+v", arcs)
  53. })
  54. })
  55. })
  56. }
  57. func TestDaoNewListBakCache(t *testing.T) {
  58. convey.Convey("NewListBakCache", t, func(ctx convey.C) {
  59. var (
  60. c = context.Background()
  61. rid = int32(0)
  62. tp = int8(0)
  63. start = int(0)
  64. end = int(0)
  65. )
  66. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  67. arcs, count, err := d.NewListBakCache(c, rid, tp, start, end)
  68. ctx.Convey("Then err should be nil.arcs,count should not be nil.", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. ctx.So(count, convey.ShouldNotBeNil)
  71. ctx.Printf("%+v", arcs)
  72. })
  73. })
  74. })
  75. }
  76. func TestDaoSetNewListCache(t *testing.T) {
  77. convey.Convey("SetNewListCache", t, func(ctx convey.C) {
  78. var (
  79. c = context.Background()
  80. rid = int32(0)
  81. tp = int8(0)
  82. arcs = []*api.Arc{}
  83. count = int(0)
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. err := d.SetNewListCache(c, rid, tp, arcs, count)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }
  93. func TestDaofrom(t *testing.T) {
  94. convey.Convey("from", t, func(ctx convey.C) {
  95. var (
  96. i = int64(0)
  97. )
  98. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  99. p1 := from(i)
  100. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  101. ctx.So(p1, convey.ShouldNotBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaocombine(t *testing.T) {
  107. convey.Convey("combine", t, func(ctx convey.C) {
  108. var (
  109. pubdate = time.Time(xtime.Now().Unix())
  110. count = int(0)
  111. )
  112. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  113. p1 := combine(pubdate, count)
  114. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  115. ctx.So(p1, convey.ShouldNotBeNil)
  116. })
  117. })
  118. })
  119. }