report_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/admin/main/reply/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDataReport(t *testing.T) {
  10. var (
  11. typ = int32(12)
  12. oid = int64(909)
  13. rpID = int64(111845851)
  14. oids = []int64{909}
  15. rpIDs = []int64{111845851}
  16. now = time.Now()
  17. c = context.Background()
  18. )
  19. Convey("report info", t, WithDao(func(d *Dao) {
  20. rpt, err := d.Report(c, oid, rpID)
  21. So(err, ShouldBeNil)
  22. So(rpt.RpID, ShouldEqual, rpID)
  23. rpts, err := d.Reports(c, oids, rpIDs)
  24. So(err, ShouldBeNil)
  25. So(len(rpts), ShouldEqual, 1)
  26. rptm, err := d.ReportByOids(c, typ, oids...)
  27. So(err, ShouldBeNil)
  28. So(len(rptm), ShouldNotEqual, 0)
  29. }))
  30. Convey("report state update", t, WithDao(func(d *Dao) {
  31. _, err := d.UpReportsState(c, oids, rpIDs, model.ReportStateDelete, now)
  32. So(err, ShouldBeNil)
  33. rpt, err := d.Report(c, oids[0], rpIDs[0])
  34. So(err, ShouldBeNil)
  35. So(rpt.State, ShouldEqual, model.ReportStateDelete)
  36. }))
  37. Convey("report reason update", t, WithDao(func(d *Dao) {
  38. _, err := d.UpReportsStateWithReason(c, oids, rpIDs, model.ReportStateDelete, 1, "test", now)
  39. So(err, ShouldBeNil)
  40. rpt, err := d.Report(c, oids[0], rpIDs[0])
  41. So(err, ShouldBeNil)
  42. So(rpt.State, ShouldEqual, model.ReportStateDelete)
  43. So(rpt.Reason, ShouldEqual, 1)
  44. So(rpt.Content, ShouldEqual, "test")
  45. }))
  46. Convey("report attr update", t, WithDao(func(d *Dao) {
  47. _, err := d.UpReportsAttrBit(c, oids, rpIDs, model.ReportAttrTransferred, model.AttrYes, now)
  48. So(err, ShouldBeNil)
  49. rpt, err := d.Report(c, oids[0], rpIDs[0])
  50. So(err, ShouldBeNil)
  51. So(rpt.AttrVal(model.ReportAttrTransferred), ShouldEqual, model.AttrYes)
  52. }))
  53. }