mysql_protect_test.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/dm/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoAddProtectApply(t *testing.T) {
  9. convey.Convey("AddProtectApply", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. pas = []*model.Pa{
  13. {
  14. ID: 123,
  15. CID: 1,
  16. UID: 1,
  17. },
  18. }
  19. )
  20. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  21. affect, err := testDao.AddProtectApply(c, pas)
  22. convCtx.Convey("Then err should be nil.affect should not be nil.", func(convCtx convey.C) {
  23. convCtx.So(err, convey.ShouldBeNil)
  24. convCtx.So(affect, convey.ShouldNotBeNil)
  25. })
  26. })
  27. })
  28. }
  29. func TestDaoProtectApplyTime(t *testing.T) {
  30. convey.Convey("ProtectApplyTime", t, func(convCtx convey.C) {
  31. var (
  32. c = context.Background()
  33. dmid = int64(0)
  34. )
  35. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  36. no, err := testDao.ProtectApplyTime(c, dmid)
  37. convCtx.Convey("Then err should be nil.no should not be nil.", func(convCtx convey.C) {
  38. convCtx.So(err, convey.ShouldBeNil)
  39. convCtx.So(no, convey.ShouldNotBeNil)
  40. })
  41. })
  42. })
  43. }
  44. func TestDaoProtectApplies(t *testing.T) {
  45. convey.Convey("ProtectApplies", t, func(convCtx convey.C) {
  46. var (
  47. c = context.Background()
  48. uid = int64(123)
  49. aid = int64(111)
  50. order = ""
  51. )
  52. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  53. _, err := testDao.ProtectApplies(c, uid, aid, order)
  54. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  55. convCtx.So(err, convey.ShouldBeNil)
  56. })
  57. })
  58. })
  59. }
  60. func TestDaoProtectAids(t *testing.T) {
  61. convey.Convey("ProtectAids", t, func(convCtx convey.C) {
  62. var (
  63. c = context.Background()
  64. uid = int64(0)
  65. )
  66. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  67. res, err := testDao.ProtectAids(c, uid)
  68. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  69. convCtx.So(err, convey.ShouldBeNil)
  70. convCtx.So(res, convey.ShouldNotBeNil)
  71. })
  72. })
  73. })
  74. }
  75. func TestDaoUptPaStatus(t *testing.T) {
  76. convey.Convey("UptPaStatus", t, func(convCtx convey.C) {
  77. var (
  78. c = context.Background()
  79. uid = int64(123)
  80. ids = "123"
  81. status = int(0)
  82. )
  83. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  84. affect, err := testDao.UptPaStatus(c, uid, ids, status)
  85. convCtx.Convey("Then err should be nil.affect should not be nil.", func(convCtx convey.C) {
  86. convCtx.So(err, convey.ShouldBeNil)
  87. convCtx.So(affect, convey.ShouldNotBeNil)
  88. })
  89. })
  90. })
  91. }
  92. func TestDaoProtectApplyByIDs(t *testing.T) {
  93. convey.Convey("ProtectApplyByIDs", t, func(convCtx convey.C) {
  94. var (
  95. c = context.Background()
  96. uid = int64(123)
  97. ids = "123"
  98. )
  99. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  100. res, err := testDao.ProtectApplyByIDs(c, uid, ids)
  101. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  102. convCtx.So(err, convey.ShouldBeNil)
  103. convCtx.So(res, convey.ShouldNotBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoUptPaNoticeSwitch(t *testing.T) {
  109. convey.Convey("UptPaNoticeSwitch", t, func(convCtx convey.C) {
  110. var (
  111. c = context.Background()
  112. uid = int64(0)
  113. status = int(0)
  114. )
  115. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  116. affect, err := testDao.UptPaNoticeSwitch(c, uid, status)
  117. convCtx.Convey("Then err should be nil.affect should not be nil.", func(convCtx convey.C) {
  118. convCtx.So(err, convey.ShouldBeNil)
  119. convCtx.So(affect, convey.ShouldNotBeNil)
  120. })
  121. })
  122. })
  123. }
  124. func TestDaoPaNoticeClose(t *testing.T) {
  125. convey.Convey("PaNoticeClose", t, func(convCtx convey.C) {
  126. var (
  127. c = context.Background()
  128. uids = []int64{123}
  129. )
  130. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  131. res, err := testDao.PaNoticeClose(c, uids)
  132. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  133. convCtx.So(err, convey.ShouldBeNil)
  134. convCtx.So(res, convey.ShouldNotBeNil)
  135. })
  136. })
  137. })
  138. }
  139. func TestDaoProtectApplyStatistics(t *testing.T) {
  140. convey.Convey("ProtectApplyStatistics", t, func(convCtx convey.C) {
  141. var (
  142. c = context.Background()
  143. )
  144. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  145. res, err := testDao.ProtectApplyStatistics(c)
  146. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  147. convCtx.So(err, convey.ShouldBeNil)
  148. convCtx.So(res, convey.ShouldNotBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaotwoDayAgo22(t *testing.T) {
  154. convey.Convey("twoDayAgo22", t, func(convCtx convey.C) {
  155. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  156. p1 := twoDayAgo22()
  157. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  158. convCtx.So(p1, convey.ShouldNotBeNil)
  159. })
  160. })
  161. })
  162. }
  163. func TestDaoPaUsrStat(t *testing.T) {
  164. convey.Convey("PaUsrStat", t, func(convCtx convey.C) {
  165. var (
  166. c = context.Background()
  167. )
  168. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  169. res, err := testDao.PaUsrStat(c)
  170. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  171. convCtx.So(err, convey.ShouldBeNil)
  172. convCtx.So(res, convey.ShouldNotBeNil)
  173. })
  174. })
  175. })
  176. }