service_test.go 539 B

123456789101112131415161718192021222324252627282930313233343536
  1. package pgc
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "testing"
  6. "time"
  7. "go-common/app/job/main/tv/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. srv *Service
  12. )
  13. func init() {
  14. dir, _ := filepath.Abs("../../cmd/tv-job-test.toml")
  15. flag.Set("conf", dir)
  16. conf.Init()
  17. srv = New(conf.Conf)
  18. time.Sleep(time.Second)
  19. }
  20. func WithService(f func(s *Service)) func() {
  21. return func() {
  22. f(srv)
  23. }
  24. }
  25. func TestService_SearchSug(t *testing.T) {
  26. Convey("TestService_SearchSug", t, WithService(func(s *Service) {
  27. s.searchSug()
  28. }))
  29. }