redis_test.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoSetLinkMailCount(t *testing.T) {
  8. var (
  9. c = context.Background()
  10. linkMail = "2459593393@qq.com"
  11. )
  12. convey.Convey("SetLinkMailCount", t, func(ctx convey.C) {
  13. state, err := d.SetLinkMailCount(c, linkMail)
  14. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx convey.C) {
  15. ctx.So(err, convey.ShouldBeNil)
  16. ctx.So(state, convey.ShouldNotBeNil)
  17. })
  18. })
  19. }
  20. func TestDaogetSubtime(t *testing.T) {
  21. convey.Convey("getSubtime", t, func(ctx convey.C) {
  22. subtime := getSubtime()
  23. ctx.Convey("Then subtime should not be nil.", func(ctx convey.C) {
  24. ctx.So(subtime, convey.ShouldNotBeNil)
  25. })
  26. })
  27. }
  28. func TestDaokeyCaptcha(t *testing.T) {
  29. var (
  30. mid = int64(0)
  31. linkMail = "2459593393@qq.com"
  32. )
  33. convey.Convey("keyCaptcha", t, func(ctx convey.C) {
  34. p1 := keyCaptcha(mid, linkMail)
  35. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  36. ctx.So(p1, convey.ShouldNotBeNil)
  37. })
  38. })
  39. }
  40. func TestDaoSetCaptcha(t *testing.T) {
  41. var (
  42. c = context.Background()
  43. code = "1234"
  44. mid = int64(1)
  45. linkMail = "2459593393@qq.com"
  46. )
  47. convey.Convey("SetCaptcha", t, func(ctx convey.C) {
  48. err := d.SetCaptcha(c, code, mid, linkMail)
  49. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. })
  52. })
  53. }
  54. func TestDaoGetEMailCode(t *testing.T) {
  55. var (
  56. c = context.Background()
  57. mid = int64(1)
  58. linkMail = "2459593393@qq.com"
  59. )
  60. convey.Convey("GetEMailCode", t, func(ctx convey.C) {
  61. code, err := d.GetEMailCode(c, mid, linkMail)
  62. ctx.Convey("Then err should be nil.code should not be nil.", func(ctx convey.C) {
  63. ctx.So(err, convey.ShouldBeNil)
  64. ctx.So(code, convey.ShouldNotBeNil)
  65. })
  66. })
  67. }
  68. func TestDaoDelEMailCode(t *testing.T) {
  69. var (
  70. c = context.Background()
  71. mid = int64(1)
  72. linkMail = "2459593393@qq.com"
  73. )
  74. convey.Convey("GetEMailCode", t, func(ctx convey.C) {
  75. err := d.DelEMailCode(c, mid, linkMail)
  76. ctx.Convey("Then err should be nil.code should not be nil.", func(ctx convey.C) {
  77. ctx.So(err, convey.ShouldBeNil)
  78. })
  79. })
  80. }
  81. func TestDaoPingRedis(t *testing.T) {
  82. var (
  83. c = context.Background()
  84. )
  85. convey.Convey("PingRedis", t, func(ctx convey.C) {
  86. err := d.PingRedis(c)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. }