redis_test.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package anchorReward
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestAnchorRewardlockKey(t *testing.T) {
  8. convey.Convey("lockKey", t, func(ctx convey.C) {
  9. var (
  10. key = ""
  11. )
  12. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  13. p1 := lockKey(key)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestAnchorRewardexpireCountKey(t *testing.T) {
  21. convey.Convey("expireCountKey", t, func(ctx convey.C) {
  22. var (
  23. key = ""
  24. )
  25. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  26. p1 := expireCountKey(key)
  27. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  28. ctx.So(p1, convey.ShouldNotBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestAnchorRewardDelLockCache(t *testing.T) {
  34. convey.Convey("DelLockCache", t, func(ctx convey.C) {
  35. var (
  36. c = context.Background()
  37. k = ""
  38. )
  39. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  40. err := d.DelLockCache(c, k)
  41. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestAnchorRewardGetExpireCountCache(t *testing.T) {
  48. convey.Convey("GetExpireCountCache", t, func(ctx convey.C) {
  49. var (
  50. c = context.Background()
  51. k = ""
  52. )
  53. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  54. count, err := d.GetExpireCountCache(c, k)
  55. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldBeNil)
  57. ctx.So(count, convey.ShouldNotBeNil)
  58. })
  59. })
  60. })
  61. }
  62. func TestAnchorRewardAddExpireCountCache(t *testing.T) {
  63. convey.Convey("AddExpireCountCache", t, func(ctx convey.C) {
  64. var (
  65. c = context.Background()
  66. k = ""
  67. times = int64(0)
  68. )
  69. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  70. err := d.AddExpireCountCache(c, k, times)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestAnchorRewardClearExpireCountCache(t *testing.T) {
  78. convey.Convey("ClearExpireCountCache", t, func(ctx convey.C) {
  79. var (
  80. c = context.Background()
  81. k = ""
  82. )
  83. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  84. err := d.ClearExpireCountCache(c, k)
  85. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  86. ctx.So(err, convey.ShouldBeNil)
  87. })
  88. })
  89. })
  90. }
  91. func TestAnchorRewardSetNxLock(t *testing.T) {
  92. convey.Convey("SetNxLock", t, func(ctx convey.C) {
  93. var (
  94. c = context.Background()
  95. k = ""
  96. times = int64(0)
  97. )
  98. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  99. res, err := d.SetNxLock(c, k, times)
  100. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  101. ctx.So(err, convey.ShouldBeNil)
  102. ctx.So(res, convey.ShouldNotBeNil)
  103. })
  104. })
  105. })
  106. }