service_test.go 372 B

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