redis_test.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoaccLoginKey(t *testing.T) {
  9. convey.Convey("accLoginKey", t, func(ctx convey.C) {
  10. var (
  11. mid = int64(1)
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. p1 := accLoginKey(mid)
  15. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  16. ctx.So(p1, convey.ShouldContainSubstring, fmt.Sprintf(_accLogin, mid))
  17. })
  18. })
  19. })
  20. }
  21. func TestDaoRemQueue(t *testing.T) {
  22. convey.Convey("RemQueue", t, func(ctx convey.C) {
  23. var (
  24. c = context.Background()
  25. mid = int64(1)
  26. )
  27. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  28. err := d.RemQueue(c, mid)
  29. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. })
  32. })
  33. })
  34. }
  35. func TestDaoDelRedisCache(t *testing.T) {
  36. convey.Convey("DelRedisCache", t, func(ctx convey.C) {
  37. var (
  38. c = context.Background()
  39. mid = int64(1)
  40. )
  41. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  42. err := d.DelRedisCache(c, mid)
  43. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. })
  46. })
  47. })
  48. }
  49. func TestDaoLoginCount(t *testing.T) {
  50. convey.Convey("LoginCount", t, func(ctx convey.C) {
  51. var (
  52. c = context.Background()
  53. mid = int64(1)
  54. )
  55. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  56. count, err := d.LoginCount(c, mid)
  57. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. ctx.So(count, convey.ShouldBeGreaterThanOrEqualTo, 0)
  60. })
  61. })
  62. })
  63. }
  64. func TestDaoFrozenTime(t *testing.T) {
  65. convey.Convey("FrozenTime", t, func(ctx convey.C) {
  66. var (
  67. c = context.Background()
  68. mid = int64(1)
  69. )
  70. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  71. frozenTime, err := d.FrozenTime(c, mid)
  72. ctx.Convey("Then err should be nil.frozenTime should not be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. ctx.So(frozenTime, convey.ShouldBeGreaterThanOrEqualTo, 0)
  75. })
  76. })
  77. })
  78. }