creative_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package creative
  2. import (
  3. "context"
  4. "go-common/app/interface/main/videoup/model/archive"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. gock "gopkg.in/h2non/gock.v1"
  8. )
  9. func TestCreativeSetWatermark(t *testing.T) {
  10. convey.Convey("SetWatermark", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. mid = int64(2089809)
  14. state = int8(1)
  15. ty = int8(3)
  16. pos = int8(1)
  17. ip = "127.0.0.1"
  18. )
  19. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  20. defer gock.OffAll()
  21. httpMock("Post", d.setWatermarkURL).Reply(200).JSON(`{"code":0,"data":{"id":53,"mid":27515310,"uname":"1qs314567","state":2,"type":2,"position":4,"url":"http://i0.hdslb.com/bfs/article/578a61e7caf47b5deaa80940b2806f1d9ce53dde.png","md5":"79d02f08c2b7b0d2b30a6b6a4f61c97e","info":"{\"width\":325,\"height\":50}","ctime":1499764110,"mtime":1499828335},"message":"","ttl":1}`)
  22. err := d.SetWatermark(c, mid, state, ty, pos, ip)
  23. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  24. ctx.So(err, convey.ShouldBeNil)
  25. })
  26. })
  27. })
  28. }
  29. func TestCreativeUploadMaterial(t *testing.T) {
  30. convey.Convey("UploadMaterial", t, func(ctx convey.C) {
  31. var (
  32. c = context.Background()
  33. editors = []*archive.Editor{}
  34. aid = int64(10110826)
  35. mid = int64(2089809)
  36. ip = "127.0.0.1"
  37. )
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. defer gock.OffAll()
  40. httpMock("Post", d.uploadMaterialURL).Reply(200).JSON(`{"code":0,"data":""}`)
  41. err := d.UploadMaterial(c, editors, aid, mid, ip)
  42. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }