report_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package service
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/admin/main/reply/model"
  6. "testing"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestReport(t *testing.T) {
  10. c := context.Background()
  11. Convey("report del and recover", t, WithService(func(s *Service) {
  12. sub, err := s.subject(c, 5464686, 1)
  13. So(err, ShouldBeNil)
  14. err = s.reportDel(c, []int64{5464686}, []int64{894726080}, 23, 0, 1, 2, 0, 0, 0, false, "testadmin", "test", "content")
  15. So(err, ShouldBeNil)
  16. rpt, err := s.report(c, 5464686, 894726080)
  17. So(err, ShouldBeNil)
  18. So(rpt.State, ShouldEqual, model.ReportStateDelete2)
  19. rp, err := s.reply(c, 5464686, 894726080)
  20. So(err, ShouldBeNil)
  21. So(rp.State, ShouldEqual, model.StateDelAdmin)
  22. sub2, err := s.subject(c, 5464686, 1)
  23. So(err, ShouldBeNil)
  24. So(sub2.RCount-sub.RCount, ShouldEqual, -1)
  25. So(sub2.ACount-sub.ACount, ShouldEqual, -1)
  26. alog, err := s.dao.AdminLog(c, 894726080)
  27. So(err, ShouldBeNil)
  28. So(alog.State, ShouldEqual, model.AdminOperRptDel2)
  29. err = s.reportRecover(c, []int64{5464686}, []int64{894726080}, 23, 1, 2, "test")
  30. So(err, ShouldBeNil)
  31. rpt, err = s.report(c, 5464686, 894726080)
  32. So(err, ShouldBeNil)
  33. So(rpt.State, ShouldEqual, model.ReportStateIgnore2)
  34. rp, err = s.reply(c, 5464686, 894726080)
  35. So(err, ShouldBeNil)
  36. So(rp.State, ShouldEqual, model.StateNormal)
  37. sub2, err = s.subject(c, 5464686, 1)
  38. So(err, ShouldBeNil)
  39. So(sub2.RCount-sub.RCount, ShouldEqual, 0)
  40. So(sub2.ACount-sub.ACount, ShouldEqual, 0)
  41. alog, err = s.dao.AdminLog(c, 894726080)
  42. So(err, ShouldBeNil)
  43. So(alog.State, ShouldEqual, model.AdminOperRptRecover2)
  44. }))
  45. Convey("reply transfer", t, WithService(func(s *Service) {
  46. err := s.ReportTransfer(c, []int64{5464686}, []int64{894726080}, 23, "asd", 1, 2, "test")
  47. So(err, ShouldBeNil)
  48. rpt, err := s.report(c, 5464686, 894726080)
  49. So(err, ShouldBeNil)
  50. So(rpt.State, ShouldEqual, model.ReportStateNew2)
  51. So(rpt.AttrVal(model.ReportAttrTransferred), ShouldEqual, model.AttrYes)
  52. s.dao.UpReportsAttrBit(c, []int64{5464686}, []int64{894726080}, model.ReportAttrTransferred, model.AttrNo, time.Now())
  53. }))
  54. Convey("reply ignore", t, WithService(func(s *Service) {
  55. err := s.ReportIgnore(c, []int64{5464686}, []int64{894726080}, 23, "asd", 1, 2, "test", false)
  56. rpt, err := s.report(c, 5464686, 894726080)
  57. So(err, ShouldBeNil)
  58. So(rpt.State, ShouldEqual, model.ReportStateIgnore2)
  59. }))
  60. }