go-common/app/job/main/playlist/service/service_test.go
2019-04-22 18:49:16 +08:00

40 lines
586 B
Go

package service
import (
"context"
"flag"
"path/filepath"
"testing"
"time"
"go-common/app/job/main/playlist/conf"
. "github.com/smartystreets/goconvey/convey"
)
var (
svr *Service
)
func init() {
dir, _ := filepath.Abs("../cmd/playlist-job-test.toml")
flag.Set("conf", dir)
conf.Init()
svr = New(conf.Conf)
time.Sleep(time.Second)
}
func WithService(f func(s *Service)) func() {
return func() {
f(svr)
}
}
func TestService_Ping(t *testing.T) {
Convey("test ping", t, WithService(func(s *Service) {
err := s.Ping(context.TODO())
So(err, ShouldBeNil)
}))
}