service_test.go 363 B

123456789101112131415161718192021222324252627
  1. package web
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "time"
  6. "go-common/app/job/main/web-goblin/conf"
  7. )
  8. var (
  9. srv *Service
  10. )
  11. func init() {
  12. dir, _ := filepath.Abs("../../cmd/web-goblin-job-test.toml")
  13. flag.Set("conf", dir)
  14. conf.Init()
  15. srv = New(conf.Conf)
  16. time.Sleep(time.Second)
  17. }
  18. func WithService(f func(s *Service)) func() {
  19. return func() {
  20. f(srv)
  21. }
  22. }