service_test.go 782 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/job/main/activity/conf"
  9. l "go-common/app/job/main/activity/model/like"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var svf *Service
  13. func init() {
  14. dir, _ := filepath.Abs("../../cmd/activity-job-test.toml")
  15. flag.Set("conf", dir)
  16. if err := conf.Init(); err != nil {
  17. panic(err)
  18. }
  19. if svf == nil {
  20. svf = New(conf.Conf)
  21. }
  22. time.Sleep(time.Second)
  23. }
  24. func WithService(f func(s *Service)) func() {
  25. return func() {
  26. f(svf)
  27. }
  28. }
  29. func TestService_LikeArc(t *testing.T) {
  30. Convey("test archive view", t, WithService(func(s *Service) {
  31. sub := &l.Subject{
  32. ID: 1,
  33. }
  34. res, err := s.likeArc(context.Background(), sub)
  35. So(err, ShouldBeNil)
  36. So(res, ShouldNotBeNil)
  37. }))
  38. }