tidb_test.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoBusiness(t *testing.T) {
  9. convey.Convey("Business", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. )
  13. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  14. res, err := d.Business(c)
  15. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  16. convCtx.So(err, convey.ShouldBeNil)
  17. convCtx.So(res, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoUserLikes(t *testing.T) {
  23. convey.Convey("UserLikes", t, func(convCtx convey.C) {
  24. var (
  25. c = context.Background()
  26. mid = int64(2233)
  27. businessID = int64(33)
  28. typ = int8(1)
  29. limit = int(100)
  30. )
  31. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  32. res, err := d.UserLikes(c, mid, businessID, typ, limit)
  33. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  34. convCtx.So(err, convey.ShouldBeNil)
  35. convCtx.So(res, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoItemLikes(t *testing.T) {
  41. convey.Convey("ItemLikes", t, func(convCtx convey.C) {
  42. var (
  43. c = context.Background()
  44. businessID = int64(33)
  45. originID = int64(7788)
  46. messageID = int64(5566)
  47. typ = int8(1)
  48. limit = int(100)
  49. )
  50. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  51. res, err := d.ItemLikes(c, businessID, originID, messageID, typ, limit)
  52. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  53. convCtx.So(err, convey.ShouldBeNil)
  54. convCtx.So(res, convey.ShouldNotBeNil)
  55. })
  56. })
  57. })
  58. }
  59. func TestDaoUpdateLikeState(t *testing.T) {
  60. convey.Convey("UpdateLikeState", t, func(convCtx convey.C) {
  61. var (
  62. c = context.Background()
  63. mid = int64(2233)
  64. businessID = int64(33)
  65. originID = int64(7788)
  66. messageID = int64(5566)
  67. state = int8(1)
  68. likeTime = time.Now()
  69. )
  70. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  71. res, err := d.UpdateLikeState(c, mid, businessID, originID, messageID, state, likeTime)
  72. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  73. convCtx.So(err, convey.ShouldBeNil)
  74. convCtx.So(res, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestDaoUpdateCounts(t *testing.T) {
  80. convey.Convey("UpdateCounts", t, func(convCtx convey.C) {
  81. var (
  82. c = context.Background()
  83. businessID = int64(33)
  84. originID = int64(7788)
  85. messageID = int64(5566)
  86. likeCounts = int64(100)
  87. dislikeCounts = int64(100)
  88. upMid = int64(999)
  89. )
  90. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  91. err := d.UpdateCounts(c, businessID, originID, messageID, likeCounts, dislikeCounts, upMid)
  92. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  93. convCtx.So(err, convey.ShouldBeNil)
  94. })
  95. })
  96. })
  97. }
  98. func TestDaoStat(t *testing.T) {
  99. convey.Convey("Stat", t, func(convCtx convey.C) {
  100. var (
  101. c = context.Background()
  102. businessID = int64(33)
  103. originID = int64(7788)
  104. messageID = int64(5566)
  105. )
  106. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  107. res, err := d.Stat(c, businessID, originID, messageID)
  108. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  109. convCtx.So(err, convey.ShouldBeNil)
  110. convCtx.So(res, convey.ShouldNotBeNil)
  111. })
  112. })
  113. })
  114. }