redis_test.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaopingRedis(t *testing.T) {
  8. convey.Convey("pingRedis", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. )
  12. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  13. err := d.pingRedis(c)
  14. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestDaoRedisRPOPCids(t *testing.T) {
  21. convey.Convey("RedisRPOPCids", t, func(ctx convey.C) {
  22. var (
  23. c = context.Background()
  24. business = int8(0)
  25. round = int64(0)
  26. num = int8(0)
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. cids, err := d.RedisRPOPCids(c, business, round, num)
  30. ctx.Convey("Then err should be nil.cids should not be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. ctx.So(cids, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestDaoIsOnline(t *testing.T) {
  38. convey.Convey("IsOnline", t, func(ctx convey.C) {
  39. var (
  40. c = context.Background()
  41. assigneeAdminID = int64(0)
  42. )
  43. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  44. online, err := d.IsOnline(c, assigneeAdminID)
  45. ctx.Convey("Then err should be nil.online should not be nil.", func(ctx convey.C) {
  46. ctx.So(err, convey.ShouldBeNil)
  47. ctx.So(online, convey.ShouldNotBeNil)
  48. })
  49. })
  50. })
  51. }
  52. func TestDaoAddOnline(t *testing.T) {
  53. convey.Convey("AddOnline", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. assigneeAdminID = int64(0)
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. err := d.AddOnline(c, assigneeAdminID)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestDaoDelOnline(t *testing.T) {
  67. convey.Convey("DelOnline", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. assigneeAdminID = int64(0)
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. err := d.DelOnline(c, assigneeAdminID)
  74. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. })
  77. })
  78. })
  79. }
  80. func TestDaoListOnline(t *testing.T) {
  81. convey.Convey("ListOnline", t, func(ctx convey.C) {
  82. var (
  83. c = context.Background()
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. _, err := d.ListOnline(c)
  87. ctx.Convey("Then err should be nil.ids should not be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }
  93. func TestDaoLogInOutTime(t *testing.T) {
  94. convey.Convey("LogInOutTime", t, func(ctx convey.C) {
  95. var (
  96. c = context.Background()
  97. uids = []int64{}
  98. )
  99. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  100. d.LogInOutTime(c, uids)
  101. ctx.Convey("No return values", func(ctx convey.C) {
  102. })
  103. })
  104. })
  105. }
  106. func TestDaofieldOnlineList(t *testing.T) {
  107. convey.Convey("fieldOnlineList", t, func(ctx convey.C) {
  108. var (
  109. assigneeAdminID = int64(0)
  110. )
  111. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  112. p1 := d.fieldOnlineList(assigneeAdminID)
  113. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  114. ctx.So(p1, convey.ShouldNotBeNil)
  115. })
  116. })
  117. })
  118. }
  119. func TestDaokeyChallCount(t *testing.T) {
  120. convey.Convey("keyChallCount", t, func(ctx convey.C) {
  121. var (
  122. assigneeAdminID = int64(0)
  123. )
  124. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  125. p1 := d.keyChallCount(assigneeAdminID)
  126. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  127. ctx.So(p1, convey.ShouldNotBeNil)
  128. })
  129. })
  130. })
  131. }