memcache_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaocouponAllowancesKey(t *testing.T) {
  8. convey.Convey("couponAllowancesKey", t, func(convCtx convey.C) {
  9. var (
  10. mid = int64(0)
  11. )
  12. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  13. p1 := couponAllowancesKey(mid, 0)
  14. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  15. convCtx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestDaocouponsKey(t *testing.T) {
  21. convey.Convey("couponsKey", t, func(convCtx convey.C) {
  22. var (
  23. mid = int64(0)
  24. ct = int8(0)
  25. )
  26. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  27. p1 := couponsKey(mid, ct)
  28. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  29. convCtx.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaograntUnique(t *testing.T) {
  35. convey.Convey("grantUnique", t, func(convCtx convey.C) {
  36. var (
  37. token = ""
  38. )
  39. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  40. p1 := grantUnique(token)
  41. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  42. convCtx.So(p1, convey.ShouldNotBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestDaoDelCouponAllowancesKey(t *testing.T) {
  48. convey.Convey("DelCouponAllowancesKey", t, func(convCtx convey.C) {
  49. var (
  50. c = context.Background()
  51. mid = int64(0)
  52. )
  53. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  54. err := d.DelCouponAllowancesKey(c, mid, 0)
  55. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  56. convCtx.So(err, convey.ShouldBeNil)
  57. })
  58. })
  59. })
  60. }
  61. func TestDaodelCache(t *testing.T) {
  62. convey.Convey("delCache", t, func(convCtx convey.C) {
  63. var (
  64. c = context.Background()
  65. key = "123"
  66. )
  67. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  68. err := d.delCache(c, key)
  69. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  70. convCtx.So(err, convey.ShouldBeNil)
  71. })
  72. })
  73. })
  74. }
  75. func TestDaoDelCouponTypeCache(t *testing.T) {
  76. convey.Convey("DelCouponTypeCache", t, func(convCtx convey.C) {
  77. var (
  78. c = context.Background()
  79. mid = int64(0)
  80. ct = int8(0)
  81. )
  82. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  83. err := d.DelCouponTypeCache(c, mid, ct)
  84. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  85. convCtx.So(err, convey.ShouldBeNil)
  86. })
  87. })
  88. })
  89. }
  90. func TestDaoDelGrantUniqueLock(t *testing.T) {
  91. convey.Convey("DelGrantUniqueLock", t, func(convCtx convey.C) {
  92. var (
  93. c = context.Background()
  94. token = ""
  95. )
  96. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  97. err := d.DelGrantUniqueLock(c, token)
  98. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  99. convCtx.So(err, convey.ShouldBeNil)
  100. })
  101. })
  102. })
  103. }
  104. func TestDaoAddGrantUniqueLock(t *testing.T) {
  105. convey.Convey("AddGrantUniqueLock", t, func(convCtx convey.C) {
  106. var (
  107. c = context.Background()
  108. token = ""
  109. seconds = int32(0)
  110. )
  111. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  112. succeed := d.AddGrantUniqueLock(c, token, seconds)
  113. convCtx.Convey("Then succeed should not be nil.", func(convCtx convey.C) {
  114. convCtx.So(succeed, convey.ShouldNotBeNil)
  115. })
  116. })
  117. })
  118. }