user_stat_test.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoRawBatchUserStatistics(t *testing.T) {
  8. convey.Convey("RawBatchUserStatistics", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. mids = []int64{88895104}
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. res, err := d.RawBatchUserStatistics(c, mids)
  15. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(res, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoTxIncrUserStatisticsFollow(t *testing.T) {
  23. convey.Convey("TxIncrUserStatisticsFollow", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. mid = int64(88895104)
  27. )
  28. tx, _ := d.BeginTran(c)
  29. defer func() {
  30. tx.Rollback()
  31. }()
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. num, err := d.TxIncrUserStatisticsFollow(tx, mid)
  34. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(num, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestDaoTxIncrUserStatisticsFan(t *testing.T) {
  42. convey.Convey("TxIncrUserStatisticsFan", t, func(ctx convey.C) {
  43. var (
  44. c = context.Background()
  45. mid = int64(88895104)
  46. )
  47. tx, _ := d.BeginTran(c)
  48. defer func() {
  49. tx.Rollback()
  50. }()
  51. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  52. num, err := d.TxIncrUserStatisticsFan(tx, mid)
  53. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. ctx.So(num, convey.ShouldNotBeNil)
  56. })
  57. })
  58. })
  59. }
  60. func TestDaoTxDecrUserStatisticsFollow(t *testing.T) {
  61. convey.Convey("TxDecrUserStatisticsFollow", t, func(ctx convey.C) {
  62. var (
  63. c = context.Background()
  64. mid = int64(88895104)
  65. )
  66. tx, _ := d.BeginTran(c)
  67. defer func() {
  68. tx.Rollback()
  69. }()
  70. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  71. num, err := d.TxDecrUserStatisticsFollow(tx, mid)
  72. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. ctx.So(num, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestDaoTxDecrUserStatisticsFan(t *testing.T) {
  80. convey.Convey("TxDecrUserStatisticsFan", t, func(ctx convey.C) {
  81. var (
  82. c = context.Background()
  83. mid = int64(88895104)
  84. )
  85. tx, _ := d.BeginTran(c)
  86. defer func() {
  87. tx.Rollback()
  88. }()
  89. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  90. num, err := d.TxDecrUserStatisticsFan(tx, mid)
  91. ctx.Convey("Then err should be nil.num should not be nil.", func(ctx convey.C) {
  92. ctx.So(err, convey.ShouldBeNil)
  93. ctx.So(num, convey.ShouldNotBeNil)
  94. })
  95. })
  96. })
  97. }
  98. func TestDaoTxIncrUserStatisticsField(t *testing.T) {
  99. convey.Convey("TxIncrUserStatisticsField", t, func(ctx convey.C) {
  100. var (
  101. c = context.Background()
  102. mid = int64(88895104)
  103. field = "like_total"
  104. )
  105. tx, _ := d.BeginTran(c)
  106. defer func() {
  107. tx.Rollback()
  108. }()
  109. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  110. rowsAffected, err := d.TxIncrUserStatisticsField(c, tx, mid, field)
  111. ctx.Convey("Then err should be nil.rowsAffected should not be nil.", func(ctx convey.C) {
  112. ctx.So(err, convey.ShouldBeNil)
  113. ctx.So(rowsAffected, convey.ShouldNotBeNil)
  114. })
  115. })
  116. })
  117. }
  118. func TestDaoTxDescUserStatisticsField(t *testing.T) {
  119. convey.Convey("TxDescUserStatisticsField", t, func(ctx convey.C) {
  120. var (
  121. c = context.Background()
  122. mid = int64(88895104)
  123. field = "like_total"
  124. )
  125. tx, _ := d.BeginTran(c)
  126. defer func() {
  127. tx.Rollback()
  128. }()
  129. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  130. rowsAffected, err := d.TxDescUserStatisticsField(c, tx, mid, field)
  131. ctx.Convey("Then err should be nil.rowsAffected should not be nil.", func(ctx convey.C) {
  132. ctx.So(err, convey.ShouldBeNil)
  133. ctx.So(rowsAffected, convey.ShouldNotBeNil)
  134. })
  135. })
  136. })
  137. }