mysql_report_test.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/dm/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaorptTable(t *testing.T) {
  9. convey.Convey("rptTable", t, func(convCtx convey.C) {
  10. var (
  11. cid = int64(0)
  12. )
  13. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  14. p1 := rptTable(cid)
  15. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  16. convCtx.So(p1, convey.ShouldNotBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestDaorptUserTable(t *testing.T) {
  22. convey.Convey("rptUserTable", t, func(convCtx convey.C) {
  23. var (
  24. dmid = int64(0)
  25. )
  26. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  27. p1 := rptUserTable(dmid)
  28. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  29. convCtx.So(p1, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestDaoRptLogTable(t *testing.T) {
  35. convey.Convey("RptLogTable", t, func(convCtx convey.C) {
  36. var (
  37. dmid = int64(0)
  38. )
  39. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  40. p1 := RptLogTable(dmid)
  41. convCtx.Convey("Then p1 should not be nil.", func(convCtx convey.C) {
  42. convCtx.So(p1, convey.ShouldNotBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestDaoAddReport(t *testing.T) {
  48. convey.Convey("AddReport", t, func(convCtx convey.C) {
  49. var (
  50. c = context.Background()
  51. rpt = &model.Report{}
  52. )
  53. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  54. id, err := testDao.AddReport(c, rpt)
  55. convCtx.Convey("Then err should be nil.id should not be nil.", func(convCtx convey.C) {
  56. convCtx.So(err, convey.ShouldBeNil)
  57. convCtx.So(id, convey.ShouldNotBeNil)
  58. })
  59. })
  60. })
  61. }
  62. func TestDaoAddReportUser(t *testing.T) {
  63. convey.Convey("AddReportUser", t, func(convCtx convey.C) {
  64. var (
  65. c = context.Background()
  66. u = &model.User{}
  67. )
  68. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  69. id, err := testDao.AddReportUser(c, u)
  70. convCtx.Convey("Then err should be nil.id should not be nil.", func(convCtx convey.C) {
  71. convCtx.So(err, convey.ShouldBeNil)
  72. convCtx.So(id, convey.ShouldNotBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoReportLog(t *testing.T) {
  78. convey.Convey("ReportLog", t, func(convCtx convey.C) {
  79. var (
  80. c = context.Background()
  81. dmid = int64(0)
  82. )
  83. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  84. res, err := testDao.ReportLog(c, dmid)
  85. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  86. convCtx.So(err, convey.ShouldBeNil)
  87. convCtx.So(res, convey.ShouldNotBeNil)
  88. })
  89. })
  90. })
  91. }
  92. func TestDaoReport(t *testing.T) {
  93. convey.Convey("Report", t, func(convCtx convey.C) {
  94. var (
  95. c = context.Background()
  96. cid = int64(0)
  97. dmid = int64(0)
  98. )
  99. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  100. rpt, err := testDao.Report(c, cid, dmid)
  101. convCtx.Convey("Then err should be nil.rpt should not be nil.", func(convCtx convey.C) {
  102. convCtx.So(err, convey.ShouldBeNil)
  103. convCtx.So(rpt, convey.ShouldNotBeNil)
  104. })
  105. })
  106. })
  107. }
  108. func TestDaoUpdateReportStat(t *testing.T) {
  109. convey.Convey("UpdateReportStat", t, func(convCtx convey.C) {
  110. var (
  111. c = context.Background()
  112. cid = int64(0)
  113. dmid = int64(0)
  114. state = int8(0)
  115. )
  116. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  117. affect, err := testDao.UpdateReportStat(c, cid, dmid, state)
  118. convCtx.Convey("Then err should be nil.affect should not be nil.", func(convCtx convey.C) {
  119. convCtx.So(err, convey.ShouldBeNil)
  120. convCtx.So(affect, convey.ShouldNotBeNil)
  121. })
  122. })
  123. })
  124. }
  125. func TestDaoUpdateReportUPOp(t *testing.T) {
  126. convey.Convey("UpdateReportUPOp", t, func(convCtx convey.C) {
  127. var (
  128. c = context.Background()
  129. cid = int64(0)
  130. dmid = int64(0)
  131. op = int8(0)
  132. )
  133. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  134. affect, err := testDao.UpdateReportUPOp(c, cid, dmid, op)
  135. convCtx.Convey("Then err should be nil.affect should not be nil.", func(convCtx convey.C) {
  136. convCtx.So(err, convey.ShouldBeNil)
  137. convCtx.So(affect, convey.ShouldNotBeNil)
  138. })
  139. })
  140. })
  141. }
  142. func TestDaoAddReportLog(t *testing.T) {
  143. convey.Convey("AddReportLog", t, func(convCtx convey.C) {
  144. var (
  145. c = context.Background()
  146. lg = &model.RptLog{}
  147. )
  148. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  149. err := testDao.AddReportLog(c, lg)
  150. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  151. convCtx.So(err, convey.ShouldBeNil)
  152. })
  153. })
  154. })
  155. }
  156. func TestDaoReportUser(t *testing.T) {
  157. convey.Convey("ReportUser", t, func(convCtx convey.C) {
  158. var (
  159. c = context.Background()
  160. dmid = int64(123)
  161. )
  162. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  163. _, err := testDao.ReportUser(c, dmid)
  164. convCtx.Convey("Then err should be nil.users should not be nil.", func(convCtx convey.C) {
  165. convCtx.So(err, convey.ShouldBeNil)
  166. })
  167. })
  168. })
  169. }
  170. func TestDaoSetReportUserFinished(t *testing.T) {
  171. convey.Convey("SetReportUserFinished", t, func(convCtx convey.C) {
  172. var (
  173. c = context.Background()
  174. dmid = int64(0)
  175. )
  176. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  177. err := testDao.SetReportUserFinished(c, dmid)
  178. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  179. convCtx.So(err, convey.ShouldBeNil)
  180. })
  181. })
  182. })
  183. }