go-common/app/interface/main/creative/service/version/service_test.go
2019-04-22 18:49:16 +08:00

49 lines
896 B
Go

package version
import (
"context"
"flag"
"go-common/app/interface/main/creative/conf"
"go-common/app/interface/main/creative/model/version"
"path/filepath"
"testing"
"time"
"go-common/app/interface/main/creative/service"
. "github.com/smartystreets/goconvey/convey"
)
var (
s *Service
)
func init() {
dir, _ := filepath.Abs("../../cmd/creative.toml")
flag.Set("conf", dir)
conf.Init()
rpcdaos := service.NewRPCDaos(conf.Conf)
s = New(conf.Conf, rpcdaos)
time.Sleep(time.Second)
}
func WithService(f func(s *Service)) func() {
return func() {
Reset(func() {})
f(s)
}
}
func Test_VersionMap(t *testing.T) {
var (
c = context.Background()
err error
versions = make(map[string][]*version.Version)
)
Convey("versionMap", t, WithService(func(s *Service) {
versions, err = s.versionMap(c)
So(err, ShouldBeNil)
So(versions, ShouldNotBeNil)
}))
}