event_test.go 834 B

1234567891011121314151617181920212223242526272829303132333435
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/reply/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestEvent(t *testing.T) {
  9. var (
  10. sub = &model.Subject{}
  11. rp = &model.Reply{}
  12. rpt = &model.Report{}
  13. c = context.Background()
  14. )
  15. Convey("test pub a event for reply", t, WithService(func(s *Service) {
  16. err := s.pubEvent(c, "test", 0, sub, rp, rpt)
  17. So(err, ShouldBeNil)
  18. }))
  19. Convey("test pub a event for search index", t, WithService(func(s *Service) {
  20. rps := map[int64]*model.Reply{}
  21. rps[rp.ID] = rp
  22. err := s.pubSearchReply(c, rps, 0)
  23. So(err, ShouldBeNil)
  24. }))
  25. Convey("test pub a event for search index", t, WithService(func(s *Service) {
  26. rpts := map[int64]*model.Report{}
  27. rpts[rpt.RpID] = rpt
  28. err := s.pubSearchReport(c, rpts, nil)
  29. So(err, ShouldBeNil)
  30. }))
  31. }