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

58 lines
1.1 KiB
Go

package account
import (
"context"
"flag"
"go-common/app/interface/main/creative/conf"
accmdl "go-common/app/interface/main/creative/model/account"
"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_Account(t *testing.T) {
var (
c = context.TODO()
err error
MID = int64(2089809)
localHost = "127.0.0.1"
v *accmdl.UpInfo
m *accmdl.MyInfo
ip = ""
)
Convey("MyInfo", t, WithService(func(s *Service) {
m, err = s.MyInfo(c, MID, ip, time.Now())
So(err, ShouldBeNil)
So(m, ShouldNotBeNil)
}))
Convey("UpInfo", t, WithService(func(s *Service) {
v, err = s.UpInfo(c, MID, localHost)
So(err, ShouldBeNil)
So(v, ShouldNotBeNil)
}))
}