activity_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/workflow/model/param"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestActivityList(t *testing.T) {
  9. convey.Convey("ActivityList", t, func() {
  10. eid, err := s.AddEvent(context.Background(), &param.EventParam{
  11. Cid: int64(1),
  12. AdminID: int64(1),
  13. Content: "test.content",
  14. Attachments: "test.attachments",
  15. Event: int8(1),
  16. })
  17. convey.So(err, convey.ShouldBeNil)
  18. convey.So(eid, convey.ShouldNotEqual, 0)
  19. elist, err := s.ListEvent(context.Background(), 1)
  20. convey.So(err, convey.ShouldBeNil)
  21. eids := make([]int64, 0)
  22. for _, e := range elist {
  23. eids = append(eids, e.Eid)
  24. }
  25. convey.So(eid, convey.ShouldBeIn, eids)
  26. acts, err := s.ActivityList(context.Background(), int8(1), 1)
  27. convey.So(err, convey.ShouldBeNil)
  28. convey.So(acts, convey.ShouldNotBeNil)
  29. convey.So(acts.Events, convey.ShouldNotBeEmpty)
  30. convey.So(acts.Logs, convey.ShouldNotBeEmpty)
  31. eids2 := make([]int64, 0)
  32. for _, e := range acts.Events {
  33. eids2 = append(eids2, e.Eid)
  34. }
  35. convey.So(eid, convey.ShouldBeIn, eids2)
  36. })
  37. }