go-common/app/interface/main/creative/service/version/service_test.go

49 lines
896 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
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)
}))
}