redis_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package dao
  2. import (
  3. "testing"
  4. "github.com/smartystreets/goconvey/convey"
  5. )
  6. func TestDaokeyBuyFlag(t *testing.T) {
  7. convey.Convey("keyBuyFlag", t, func(ctx convey.C) {
  8. var (
  9. mid = int64(0)
  10. )
  11. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  12. p1 := keyBuyFlag(mid)
  13. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  14. ctx.So(p1, convey.ShouldNotBeNil)
  15. })
  16. })
  17. })
  18. }
  19. func TestDaokeyApplyFlag(t *testing.T) {
  20. convey.Convey("keyApplyFlag", t, func(ctx convey.C) {
  21. var (
  22. code = ""
  23. )
  24. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  25. p1 := keyApplyFlag(code)
  26. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  27. ctx.So(p1, convey.ShouldNotBeNil)
  28. })
  29. })
  30. })
  31. }
  32. func TestDaopingRedis(t *testing.T) {
  33. convey.Convey("pingRedis", t, func(ctx convey.C) {
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. err := d.pingRedis(c)
  36. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. })
  39. })
  40. })
  41. }
  42. func TestDaoSetBuyFlagCache(t *testing.T) {
  43. convey.Convey("SetBuyFlagCache", t, func(ctx convey.C) {
  44. var (
  45. mid = int64(0)
  46. f = ""
  47. )
  48. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  49. ok, err := d.SetBuyFlagCache(c, mid, f)
  50. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(ok, convey.ShouldNotBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestDaoDelBuyFlagCache(t *testing.T) {
  58. convey.Convey("DelBuyFlagCache", t, func(ctx convey.C) {
  59. var (
  60. mid = int64(0)
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. err := d.DelBuyFlagCache(c, mid)
  64. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. })
  67. })
  68. })
  69. }
  70. func TestDaoSetApplyFlagCache(t *testing.T) {
  71. convey.Convey("SetApplyFlagCache", t, func(ctx convey.C) {
  72. var (
  73. code = ""
  74. f = ""
  75. )
  76. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  77. ok, err := d.SetApplyFlagCache(c, code, f)
  78. ctx.Convey("Then err should be nil.ok should not be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. ctx.So(ok, convey.ShouldNotBeNil)
  81. })
  82. })
  83. })
  84. }
  85. func TestDaoDelApplyFlagCache(t *testing.T) {
  86. convey.Convey("DelApplyFlagCache", t, func(ctx convey.C) {
  87. var (
  88. code = ""
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. err := d.DelApplyFlagCache(c, code)
  92. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. })
  95. })
  96. })
  97. }