logReport_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/reply/model"
  5. "testing"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestReportLog(t *testing.T) {
  9. sp := model.LogSearchParam{
  10. Oid: 10099866,
  11. Type: 1,
  12. }
  13. c := context.Background()
  14. Convey("test top ReportLog", t, WithDao(func(d *Dao) {
  15. sp.Action = "top"
  16. data, err := d.ReportLog(c, sp)
  17. So(err, ShouldBeNil)
  18. So(data.Page.Total, ShouldEqual, 1)
  19. }))
  20. Convey("test monitor ReportLog", t, WithDao(func(d *Dao) {
  21. sp.Action = "monitor"
  22. data, err := d.ReportLog(c, sp)
  23. So(err, ShouldBeNil)
  24. So(data.Page.Total, ShouldEqual, 14)
  25. }))
  26. Convey("test subject groupby ReportLog", t, WithDao(func(d *Dao) {
  27. sp.Action = "subject_allow,subject_forbid,subject_frozen,subject_unfrozen_allow,subject_unfrozen_forbid"
  28. sp.Oid = 0
  29. data, err := d.ReportLog(c, sp)
  30. So(err, ShouldBeNil)
  31. So(data.Page.Total, ShouldEqual, 67)
  32. }))
  33. Convey("test one subject ReportLog", t, WithDao(func(d *Dao) {
  34. sp.Action = "subject_allow,subject_forbid,subject_frozen,subject_unfrozen_allow,subject_unfrozen_forbid"
  35. sp.Appid = "log_audit"
  36. sp.Oid = 10099866
  37. data, err := d.ReportLog(c, sp)
  38. So(err, ShouldBeNil)
  39. So(data.Page.Total, ShouldEqual, 2)
  40. }))
  41. }