prompt_redis_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoupPrompt(t *testing.T) {
  9. var (
  10. mid = int64(1)
  11. ts = time.Now().Unix()
  12. )
  13. convey.Convey("upPrompt", t, func(cv convey.C) {
  14. p1 := d.upPrompt(mid, ts)
  15. cv.Convey("Then p1 should not be nil.", func(cv convey.C) {
  16. cv.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. }
  20. func TestDaobuPrompt(t *testing.T) {
  21. var (
  22. btype = int8(1)
  23. mid = int64(1)
  24. ts = time.Now().Unix()
  25. )
  26. convey.Convey("buPrompt", t, func(cv convey.C) {
  27. p1 := d.buPrompt(btype, mid, ts)
  28. cv.Convey("Then p1 should not be nil.", func(cv convey.C) {
  29. cv.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. }
  33. func TestDaoIncrPromptCount(t *testing.T) {
  34. var (
  35. c = context.Background()
  36. mid = int64(1)
  37. fid = int64(2)
  38. ts = time.Now().Unix()
  39. btype = int8(1)
  40. )
  41. convey.Convey("IncrPromptCount", t, func(cv convey.C) {
  42. ucount, bcount, err := d.IncrPromptCount(c, mid, fid, ts, btype)
  43. cv.Convey("Then err should be nil.ucount,bcount should not be nil.", func(cv convey.C) {
  44. cv.So(err, convey.ShouldBeNil)
  45. cv.So(bcount, convey.ShouldNotBeNil)
  46. cv.So(ucount, convey.ShouldNotBeNil)
  47. })
  48. })
  49. }
  50. func TestDaoClosePrompt(t *testing.T) {
  51. var (
  52. c = context.Background()
  53. mid = int64(1)
  54. fid = int64(2)
  55. ts = time.Now().Unix()
  56. btype = int8(1)
  57. )
  58. convey.Convey("ClosePrompt", t, func(cv convey.C) {
  59. err := d.ClosePrompt(c, mid, fid, ts, btype)
  60. cv.Convey("Then err should be nil.", func(cv convey.C) {
  61. cv.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. }
  65. func TestDaoUpCount(t *testing.T) {
  66. var (
  67. c = context.Background()
  68. mid = int64(1)
  69. fid = int64(2)
  70. ts = time.Now().Unix()
  71. )
  72. convey.Convey("UpCount", t, func(cv convey.C) {
  73. count, err := d.UpCount(c, mid, fid, ts)
  74. cv.Convey("Then err should be nil.count should not be nil.", func(cv convey.C) {
  75. cv.So(err, convey.ShouldBeNil)
  76. cv.So(count, convey.ShouldNotBeNil)
  77. })
  78. })
  79. }
  80. func TestDaoBCount(t *testing.T) {
  81. var (
  82. c = context.Background()
  83. mid = int64(1)
  84. btype = int8(1)
  85. ts = time.Now().Unix()
  86. )
  87. convey.Convey("BCount", t, func(cv convey.C) {
  88. count, err := d.BCount(c, mid, ts, btype)
  89. cv.Convey("Then err should be nil.count should not be nil.", func(cv convey.C) {
  90. cv.So(err, convey.ShouldBeNil)
  91. cv.So(count, convey.ShouldNotBeNil)
  92. })
  93. })
  94. }