service_test.go 581 B

12345678910111213141516171819202122232425262728293031323334
  1. package watermark
  2. import (
  3. "flag"
  4. "path/filepath"
  5. "time"
  6. "go-common/app/interface/main/creative/conf"
  7. "go-common/app/interface/main/creative/service"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. s *Service
  12. p *service.Public
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../../cmd/creative.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. rpcdaos := service.NewRPCDaos(conf.Conf)
  19. p = service.New(conf.Conf, rpcdaos)
  20. s = New(conf.Conf, rpcdaos, p)
  21. time.Sleep(time.Second)
  22. }
  23. func WithService(f func(s *Service)) func() {
  24. return func() {
  25. Reset(func() {})
  26. f(s)
  27. }
  28. }