service_test.go 527 B

123456789101112131415161718192021222324252627282930313233343536
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/job/main/coin/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../cmd/coin-job-test.toml")
  16. flag.Set("conf", dir)
  17. if err := conf.Init(); err != nil {
  18. panic("conf.Init() error")
  19. }
  20. s = New(conf.Conf)
  21. time.Sleep(time.Second * 1)
  22. }
  23. func TestService(t *testing.T) {
  24. Convey("mock", t, func() {
  25. s.Close()
  26. s.Redo(0)
  27. s.Ping(context.TODO())
  28. s.Wait()
  29. })
  30. }