redis_test.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoexpAddedKey(t *testing.T) {
  8. convey.Convey("expAddedKey", t, func(convCtx convey.C) {
  9. var (
  10. tp = ""
  11. mid = int64(0)
  12. day = int(0)
  13. )
  14. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  15. p1 := expAddedKey(tp, mid, day)
  16. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  17. convCtx.So(p1, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoleader(t *testing.T) {
  23. convey.Convey("leader", t, func(convCtx convey.C) {
  24. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  25. key, value := leader()
  26. convCtx.Convey("Then key,value should not be nil.", func(convCtx convey.C) {
  27. convCtx.So(value, convey.ShouldNotBeNil)
  28. convCtx.So(key, convey.ShouldNotBeNil)
  29. })
  30. })
  31. })
  32. }
  33. func TestDaoSetExpAdded(t *testing.T) {
  34. convey.Convey("SetExpAdded", t, func(convCtx convey.C) {
  35. var (
  36. c = context.Background()
  37. mid = int64(0)
  38. day = int(0)
  39. tp = ""
  40. )
  41. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  42. b, err := d.SetExpAdded(c, mid, day, tp)
  43. convCtx.Convey("Then err should be nil.b should not be nil.", func(convCtx convey.C) {
  44. convCtx.So(err, convey.ShouldBeNil)
  45. convCtx.So(b, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestDaoExpAdded(t *testing.T) {
  51. convey.Convey("ExpAdded", t, func(convCtx convey.C) {
  52. var (
  53. c = context.Background()
  54. mid = int64(0)
  55. day = int(0)
  56. tp = ""
  57. )
  58. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  59. b, err := d.ExpAdded(c, mid, day, tp)
  60. convCtx.Convey("Then err should be nil.b should not be nil.", func(convCtx convey.C) {
  61. convCtx.So(err, convey.ShouldBeNil)
  62. convCtx.So(b, convey.ShouldNotBeNil)
  63. })
  64. })
  65. })
  66. }
  67. func TestDaoLeaderEleciton(t *testing.T) {
  68. convey.Convey("LeaderEleciton", t, func(convCtx convey.C) {
  69. var (
  70. c = context.Background()
  71. )
  72. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  73. elected := d.LeaderEleciton(c)
  74. convCtx.Convey("Then elected should not be nil.", func(convCtx convey.C) {
  75. convCtx.So(elected, convey.ShouldNotBeNil)
  76. })
  77. })
  78. })
  79. }