service_test.go 561 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "path/filepath"
  7. "testing"
  8. "go-common/app/job/main/dm2/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. svr *Service
  13. )
  14. func TestMain(m *testing.M) {
  15. var (
  16. err error
  17. )
  18. dir, _ := filepath.Abs("../cmd/dm2-job.toml")
  19. if err = flag.Set("conf", dir); err != nil {
  20. panic(err)
  21. }
  22. if err = conf.Init(); err != nil {
  23. panic(err)
  24. }
  25. svr = New(conf.Conf)
  26. os.Exit(m.Run())
  27. }
  28. func TestPing(t *testing.T) {
  29. Convey("", t, func() {
  30. err := svr.Ping(context.TODO())
  31. So(err, ShouldBeNil)
  32. })
  33. }