service_test.go 542 B

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