subtitle_test.go 916 B

12345678910111213141516171819202122232425262728293031323334
  1. package subtitle
  2. import (
  3. "context"
  4. "go-common/app/interface/main/dm2/model"
  5. "go-common/app/interface/main/dm2/rpc/client"
  6. "go-common/library/ecode"
  7. "reflect"
  8. "testing"
  9. "github.com/bouk/monkey"
  10. "github.com/smartystreets/goconvey/convey"
  11. )
  12. func TestSubtitleView(t *testing.T) {
  13. convey.Convey("View", t, func(ctx convey.C) {
  14. var (
  15. c = context.Background()
  16. aid = int64(24416433)
  17. )
  18. ctx.Convey("testSubtitleView", func(ctx convey.C) {
  19. mock := monkey.PatchInstanceMethod(reflect.TypeOf(d.sub), "SubtitleSubjectSubmitGet",
  20. func(_ *client.Service, _ context.Context, _ *model.ArgArchiveID) (res *model.SubtitleSubjectReply, err error) {
  21. return nil, ecode.CreativeSubtitleAPIErr
  22. })
  23. defer mock.Unpatch()
  24. res, err := d.View(c, aid)
  25. ctx.Convey("testSubtitleView", func(ctx convey.C) {
  26. ctx.So(err, convey.ShouldNotBeNil)
  27. ctx.So(res, convey.ShouldBeNil)
  28. })
  29. })
  30. })
  31. }