go-common/app/interface/main/creative/dao/subtitle/subtitle_test.go

35 lines
916 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package subtitle
import (
"context"
"go-common/app/interface/main/dm2/model"
"go-common/app/interface/main/dm2/rpc/client"
"go-common/library/ecode"
"reflect"
"testing"
"github.com/bouk/monkey"
"github.com/smartystreets/goconvey/convey"
)
func TestSubtitleView(t *testing.T) {
convey.Convey("View", t, func(ctx convey.C) {
var (
c = context.Background()
aid = int64(24416433)
)
ctx.Convey("testSubtitleView", func(ctx convey.C) {
mock := monkey.PatchInstanceMethod(reflect.TypeOf(d.sub), "SubtitleSubjectSubmitGet",
func(_ *client.Service, _ context.Context, _ *model.ArgArchiveID) (res *model.SubtitleSubjectReply, err error) {
return nil, ecode.CreativeSubtitleAPIErr
})
defer mock.Unpatch()
res, err := d.View(c, aid)
ctx.Convey("testSubtitleView", func(ctx convey.C) {
ctx.So(err, convey.ShouldNotBeNil)
ctx.So(res, convey.ShouldBeNil)
})
})
})
}