associate_order_test.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/service/main/vip/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoCountAssociateOrder(t *testing.T) {
  9. convey.Convey("CountAssociateOrder", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(0)
  13. appID = int64(0)
  14. )
  15. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  16. count, err := d.CountAssociateOrder(c, mid, appID)
  17. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  18. convCtx.So(err, convey.ShouldBeNil)
  19. convCtx.So(count, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoCountAssociateGrants(t *testing.T) {
  25. convey.Convey("CountAssociateGrants", t, func(convCtx convey.C) {
  26. var (
  27. c = context.Background()
  28. mid = int64(0)
  29. appID = int64(0)
  30. )
  31. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  32. count, err := d.CountAssociateGrants(c, mid, appID)
  33. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  34. convCtx.So(err, convey.ShouldBeNil)
  35. convCtx.So(count, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoCountGrantOrderByOutTradeNo(t *testing.T) {
  41. convey.Convey("CountGrantOrderByOutTradeNo", t, func(convCtx convey.C) {
  42. var (
  43. c = context.Background()
  44. outTradeNo = ""
  45. appID = int64(0)
  46. )
  47. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  48. count, err := d.CountGrantOrderByOutTradeNo(c, outTradeNo, appID)
  49. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  50. convCtx.So(err, convey.ShouldBeNil)
  51. convCtx.So(count, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDaoCountAssociateByMidAndMonths(t *testing.T) {
  57. convey.Convey("CountAssociateByMidAndMonths", t, func(convCtx convey.C) {
  58. var (
  59. c = context.Background()
  60. mid = int64(0)
  61. appID = int64(0)
  62. months = int32(0)
  63. )
  64. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  65. count, err := d.CountAssociateByMidAndMonths(c, mid, appID, months)
  66. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  67. convCtx.So(err, convey.ShouldBeNil)
  68. convCtx.So(count, convey.ShouldNotBeNil)
  69. })
  70. })
  71. })
  72. }
  73. func TestDaoTxInsertAssociateGrantOrder(t *testing.T) {
  74. convey.Convey("TxInsertAssociateGrantOrder", t, func(convCtx convey.C) {
  75. var (
  76. oa = &model.VipOrderAssociateGrant{}
  77. c = context.Background()
  78. )
  79. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  80. oldtx, err := d.OldStartTx(c)
  81. convCtx.So(err, convey.ShouldBeNil)
  82. aff, err := d.TxInsertAssociateGrantOrder(oldtx, oa)
  83. convCtx.Convey("Then err should be nil.aff should not be nil.", func(convCtx convey.C) {
  84. convCtx.So(err, convey.ShouldBeNil)
  85. convCtx.So(aff, convey.ShouldNotBeNil)
  86. })
  87. })
  88. })
  89. }
  90. func TestDaoTxUpdateAssociateGrantState(t *testing.T) {
  91. convey.Convey("TxUpdateAssociateGrantState", t, func(convCtx convey.C) {
  92. var (
  93. oa = &model.VipOrderAssociateGrant{}
  94. c = context.Background()
  95. )
  96. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  97. oldtx, err := d.OldStartTx(c)
  98. convCtx.So(err, convey.ShouldBeNil)
  99. aff, err := d.TxUpdateAssociateGrantState(oldtx, oa)
  100. convCtx.Convey("Then err should be nil.aff should not be nil.", func(convCtx convey.C) {
  101. convCtx.So(err, convey.ShouldBeNil)
  102. convCtx.So(aff, convey.ShouldNotBeNil)
  103. })
  104. })
  105. })
  106. }
  107. func TestDaoAssociateGrantCountInfo(t *testing.T) {
  108. convey.Convey("AssociateGrantCountInfo", t, func(convCtx convey.C) {
  109. var (
  110. c = context.Background()
  111. mid = int64(0)
  112. appID = int64(0)
  113. months = int32(0)
  114. )
  115. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  116. res, err := d.AssociateGrantCountInfo(c, mid, appID, months)
  117. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  118. convCtx.So(err, convey.ShouldBeNil)
  119. convCtx.So(res, convey.ShouldNotBeNil)
  120. })
  121. })
  122. })
  123. }
  124. func TestDaoAddAssociateGrantCount(t *testing.T) {
  125. convey.Convey("AddAssociateGrantCount", t, func(convCtx convey.C) {
  126. var (
  127. c = context.Background()
  128. arg = &model.VipAssociateGrantCount{}
  129. )
  130. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  131. err := d.AddAssociateGrantCount(c, arg)
  132. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  133. convCtx.So(err, convey.ShouldBeNil)
  134. })
  135. })
  136. })
  137. }
  138. func TestDaoUpdateAssociateGrantCount(t *testing.T) {
  139. convey.Convey("UpdateAssociateGrantCount", t, func(convCtx convey.C) {
  140. var (
  141. c = context.Background()
  142. arg = &model.VipAssociateGrantCount{}
  143. )
  144. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  145. err := d.UpdateAssociateGrantCount(c, arg)
  146. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  147. convCtx.So(err, convey.ShouldBeNil)
  148. })
  149. })
  150. })
  151. }