From 58b07ea5c69edc1333da416713accfa441c6d046 Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Tue, 14 Feb 2017 18:14:25 +0000 Subject: [PATCH 1/8] Starting new test suite --- duration_test.go | 91 ++++++-------- offset.go | 2 + offset_test.go | 73 +++++------ vast.go | 2 +- vast_test.go | 320 ++++------------------------------------------- 5 files changed, 101 insertions(+), 387 deletions(-) diff --git a/duration_test.go b/duration_test.go index 3f1d4ab..d9cbbb4 100644 --- a/duration_test.go +++ b/duration_test.go @@ -1,59 +1,48 @@ package vast import ( - "testing" "time" - "github.com/stretchr/testify/assert" + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/gomega" ) -func TestDurationMarshaler(t *testing.T) { - b, err := Duration(0).MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "00:00:00", string(b)) - } - b, err = Duration(2 * time.Millisecond).MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "00:00:00.002", string(b)) - } - b, err = Duration(2 * time.Second).MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "00:00:02", string(b)) - } - b, err = Duration(2 * time.Minute).MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "00:02:00", string(b)) - } - b, err = Duration(2 * time.Hour).MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "02:00:00", string(b)) - } -} +var _ = Describe("Duration", func() { -func TestDurationUnmarshal(t *testing.T) { - var d Duration - if assert.NoError(t, d.UnmarshalText([]byte("00:00:00"))) { - assert.Equal(t, Duration(0), d) - } - d = 0 - if assert.NoError(t, d.UnmarshalText([]byte("00:00:02"))) { - assert.Equal(t, Duration(2*time.Second), d) - } - d = 0 - if assert.NoError(t, d.UnmarshalText([]byte("00:02:00"))) { - assert.Equal(t, Duration(2*time.Minute), d) - } - d = 0 - if assert.NoError(t, d.UnmarshalText([]byte("02:00:00"))) { - assert.Equal(t, Duration(2*time.Hour), d) - } - d = 0 - if assert.NoError(t, d.UnmarshalText([]byte("00:00:00.123"))) { - assert.Equal(t, Duration(123*time.Millisecond), d) - } - assert.EqualError(t, d.UnmarshalText([]byte("00:00:60")), "invalid duration: 00:00:60") - assert.EqualError(t, d.UnmarshalText([]byte("00:60:00")), "invalid duration: 00:60:00") - assert.EqualError(t, d.UnmarshalText([]byte("00:00:00.-1")), "invalid duration: 00:00:00.-1") - assert.EqualError(t, d.UnmarshalText([]byte("00:00:00.1000")), "invalid duration: 00:00:00.1000") - assert.EqualError(t, d.UnmarshalText([]byte("00h01m")), "invalid duration: 00h01m") -} + DescribeTable("marshal", + func(d Duration, exp string) { + b, err := d.MarshalText() + Expect(err).NotTo(HaveOccurred()) + Expect(string(b)).To(Equal(exp)) + }, + Entry("00:00:00", Duration(0), "00:00:00"), + Entry("00:00:00.002", Duration(2*time.Millisecond), "00:00:00.002"), + Entry("00:00:02", Duration(2*time.Second), "00:00:02"), + Entry("00:02:00", Duration(2*time.Minute), "00:02:00"), + Entry("02:00:00", Duration(2*time.Hour), "02:00:00"), + ) + + DescribeTable("unmarshal", + func(s string, exp Duration) { + d := new(Duration) + Expect(d.UnmarshalText([]byte(s))).To(Succeed()) + Expect(*d).To(Equal(exp)) + }, + Entry("00:00:00", "00:00:00", Duration(0)), + Entry("00:00:00.002", "00:00:00.002", Duration(2*time.Millisecond)), + Entry("00:00:02", "00:00:02", Duration(2*time.Second)), + Entry("00:02:00", "00:02:00", Duration(2*time.Minute)), + Entry("02:00:00", "02:00:00", Duration(2*time.Hour)), + ) + + It("should fail to unmarshal bad inputs", func() { + d := new(Duration) + Expect(d.UnmarshalText([]byte("00:00:60"))).To(MatchError("invalid duration: 00:00:60")) + Expect(d.UnmarshalText([]byte("00:60:00"))).To(MatchError("invalid duration: 00:60:00")) + Expect(d.UnmarshalText([]byte("00:00:00.-1"))).To(MatchError("invalid duration: 00:00:00.-1")) + Expect(d.UnmarshalText([]byte("00:00:00.1000"))).To(MatchError("invalid duration: 00:00:00.1000")) + Expect(d.UnmarshalText([]byte("00h01m"))).To(MatchError("invalid duration: 00h01m")) + }) + +}) diff --git a/offset.go b/offset.go index 30e1e2b..d33b9e8 100644 --- a/offset.go +++ b/offset.go @@ -31,6 +31,8 @@ func (o *Offset) UnmarshalText(data []byte) error { } o.Percent = float32(p) / 100 return nil + } else { + o.Percent = 0 } var d Duration o.Duration = &d diff --git a/offset_test.go b/offset_test.go index 5651d00..33b9e60 100644 --- a/offset_test.go +++ b/offset_test.go @@ -1,45 +1,40 @@ package vast import ( - "testing" - - "github.com/stretchr/testify/assert" + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/gomega" ) -func TestOffsetMarshaler(t *testing.T) { - b, err := Offset{}.MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "0%", string(b)) - } - b, err = Offset{Percent: .1}.MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "10%", string(b)) - } - d := Duration(0) - b, err = Offset{Duration: &d}.MarshalText() - if assert.NoError(t, err) { - assert.Equal(t, "00:00:00", string(b)) - } -} +var _ = Describe("Offset", func() { + zero := Duration(0) + + DescribeTable("marshal", + func(o *Offset, exp string) { + b, err := o.MarshalText() + Expect(err).NotTo(HaveOccurred()) + Expect(string(b)).To(Equal(exp)) + }, + Entry("0%", &Offset{}, "0%"), + Entry("10%", &Offset{Percent: 0.1}, "10%"), + Entry("00:00:00", &Offset{Duration: &zero}, "00:00:00"), + ) + + DescribeTable("unmarshal", + func(s string, pc float64, dur *Duration) { + o := Offset{} + Expect(o.UnmarshalText([]byte(s))).To(Succeed()) + Expect(o.Percent).To(BeNumerically("~", pc, 0.001)) + Expect(o.Duration).To(Equal(dur)) + }, + Entry("0%", "0%", 0.0, nil), + Entry("10%", "10%", 0.1, nil), + Entry("00:00:00", "00:00:00", 0.0, &zero), + ) + + It("should fail to unmarshal bad inputs", func() { + o := new(Offset) + Expect(o.UnmarshalText([]byte("abc%"))).To(MatchError("invalid offset: abc%")) + }) -func TestOffsetUnmarshaler(t *testing.T) { - var o Offset - if assert.NoError(t, o.UnmarshalText([]byte("0%"))) { - assert.Nil(t, o.Duration) - assert.Equal(t, float32(0.0), o.Percent) - } - o = Offset{} - if assert.NoError(t, o.UnmarshalText([]byte("10%"))) { - assert.Nil(t, o.Duration) - assert.Equal(t, float32(0.1), o.Percent) - } - o = Offset{} - if assert.NoError(t, o.UnmarshalText([]byte("00:00:00"))) { - if assert.NotNil(t, o.Duration) { - assert.Equal(t, Duration(0), *o.Duration) - } - assert.Equal(t, float32(0), o.Percent) - } - o = Offset{} - assert.EqualError(t, o.UnmarshalText([]byte("abc%")), "invalid offset: abc%") -} +}) diff --git a/vast.go b/vast.go index 3f3d317..0e81190 100644 --- a/vast.go +++ b/vast.go @@ -255,7 +255,7 @@ type Linear struct { // begins playing. SkipOffset *Offset `xml:"skipoffset,attr,omitempty"` // Duration in standard time format, hh:mm:ss - Duration string + Duration *Duration AdParameters *AdParameters `xml:",omitempty"` Icons []Icon TrackingEvents []Tracking `xml:"TrackingEvents>Tracking,omitempty"` diff --git a/vast_test.go b/vast_test.go index 60665f5..19f1fd3 100644 --- a/vast_test.go +++ b/vast_test.go @@ -2,310 +2,38 @@ package vast import ( "encoding/xml" - "io/ioutil" "os" - "strings" "testing" - "github.com/stretchr/testify/assert" + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/gomega" ) -func loadFixture(path string) (*VAST, error) { - xmlFile, err := os.Open(path) - if err != nil { - return nil, err - } - defer xmlFile.Close() - b, _ := ioutil.ReadAll(xmlFile) +var _ = Describe("VAST", func() { - var v VAST - err = xml.Unmarshal(b, &v) - return &v, err -} - -func TestInlineLinear(t *testing.T) { - v, err := loadFixture("testdata/vast_inline_linear.xml") - if !assert.NoError(t, err) { - return - } - - assert.Equal(t, "2.0", v.Version) - if assert.Len(t, v.Ads, 1) { - ad := v.Ads[0] - assert.Equal(t, "601364", ad.ID) - assert.Nil(t, ad.Wrapper) - assert.Equal(t, 0, ad.Sequence) - if assert.NotNil(t, ad.InLine) { - inline := ad.InLine - assert.Equal(t, "Acudeo Compatible", inline.AdSystem.Name) - assert.Equal(t, "1.0", inline.AdSystem.Version) - assert.Equal(t, "VAST 2.0 Instream Test 1", inline.AdTitle.Name) - assert.Equal(t, "VAST 2.0 Instream Test 1", inline.Description) - if assert.Len(t, inline.Error, 2) { - assert.Equal(t, "http://myErrorURL/error", inline.Error[0].URI) - assert.Equal(t, "http://myErrorURL/error2", inline.Error[1].URI) - } - if assert.Len(t, inline.Impressions, 2) { - assert.Equal(t, "http://myTrackingURL/impression", inline.Impressions[0].URI) - assert.Equal(t, "http://myTrackingURL/impression2", inline.Impressions[1].URI) - assert.Equal(t, "foo", inline.Impressions[1].ID) - } - if assert.Len(t, inline.Creatives, 2) { - crea1 := inline.Creatives[0] - assert.Equal(t, "601364", crea1.AdID) - assert.Nil(t, crea1.NonLinearAds) - assert.Nil(t, crea1.CompanionAds) - if assert.NotNil(t, crea1.Linear) { - linear := crea1.Linear - assert.Equal(t, "00:00:30", linear.Duration) - if assert.Len(t, linear.TrackingEvents, 6) { - assert.Equal(t, linear.TrackingEvents[0].Event, "creativeView") - assert.Equal(t, linear.TrackingEvents[0].URI, "http://myTrackingURL/creativeView") - assert.Equal(t, linear.TrackingEvents[1].Event, "start") - assert.Equal(t, linear.TrackingEvents[1].URI, "http://myTrackingURL/start") - } - if assert.NotNil(t, linear.VideoClicks) { - if assert.Len(t, linear.VideoClicks.ClickThroughs, 1) { - assert.Equal(t, linear.VideoClicks.ClickThroughs[0].URI, "http://www.tremormedia.com") - } - if assert.Len(t, linear.VideoClicks.ClickTrackings, 1) { - assert.Equal(t, linear.VideoClicks.ClickTrackings[0].URI, "http://myTrackingURL/click") - } - assert.Len(t, linear.VideoClicks.CustomClicks, 0) - } - if assert.Len(t, linear.MediaFiles, 1) { - mf := linear.MediaFiles[0] - assert.Equal(t, "progressive", mf.Delivery) - assert.Equal(t, "video/x-flv", mf.Type) - assert.Equal(t, 500, mf.Bitrate) - assert.Equal(t, 400, mf.Width) - assert.Equal(t, 300, mf.Height) - assert.Equal(t, true, mf.Scalable) - assert.Equal(t, true, mf.MaintainAspectRatio) - assert.Equal(t, "http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv", mf.URI) - } - } - - crea2 := inline.Creatives[1] - assert.Equal(t, "601364-Companion", crea2.AdID) - assert.Nil(t, crea2.NonLinearAds) - assert.Nil(t, crea2.Linear) - if assert.NotNil(t, crea2.CompanionAds) { - assert.Equal(t, "all", crea2.CompanionAds.Required) - if assert.Len(t, crea2.CompanionAds.Companions, 2) { - comp1 := crea2.CompanionAds.Companions[0] - assert.Equal(t, 300, comp1.Width) - assert.Equal(t, 250, comp1.Height) - if assert.NotNil(t, comp1.StaticResource) { - assert.Equal(t, "image/jpeg", comp1.StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/Blistex1.jpg", comp1.StaticResource.URI) - } - if assert.Len(t, comp1.TrackingEvents, 1) { - assert.Equal(t, "creativeView", comp1.TrackingEvents[0].Event) - assert.Equal(t, "http://myTrackingURL/firstCompanionCreativeView", comp1.TrackingEvents[0].URI) - } - assert.Equal(t, "http://www.tremormedia.com", comp1.CompanionClickThrough) - - comp2 := crea2.CompanionAds.Companions[1] - assert.Equal(t, 728, comp2.Width) - assert.Equal(t, 90, comp2.Height) - if assert.NotNil(t, comp2.StaticResource) { - assert.Equal(t, "image/jpeg", comp2.StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg", comp2.StaticResource.URI) - } - assert.Equal(t, "http://www.tremormedia.com", comp2.CompanionClickThrough) - } - } - } - } - } -} - -func TestInlineNonLinear(t *testing.T) { - v, err := loadFixture("testdata/vast_inline_nonlinear.xml") - if !assert.NoError(t, err) { - return - } - - assert.Equal(t, "2.0", v.Version) - if assert.Len(t, v.Ads, 1) { - ad := v.Ads[0] - assert.Equal(t, "602678", ad.ID) - assert.Nil(t, ad.Wrapper) - assert.Equal(t, 0, ad.Sequence) - if assert.NotNil(t, ad.InLine) { - inline := ad.InLine - assert.Equal(t, "Acudeo Compatible", inline.AdSystem.Name) - assert.Equal(t, "NonLinear Test Campaign 1", inline.AdTitle.Name) - assert.Equal(t, "NonLinear Test Campaign 1", inline.Description) - assert.Equal(t, "http://mySurveyURL/survey", inline.Survey) - if assert.Len(t, inline.Error, 1) { - assert.Equal(t, "http://myErrorURL/error", inline.Error[0].URI) - } - if assert.Len(t, inline.Impressions, 1) { - assert.Equal(t, "http://myTrackingURL/impression", inline.Impressions[0].URI) - } - if assert.Len(t, inline.Creatives, 2) { - crea1 := inline.Creatives[0] - assert.Equal(t, "602678-NonLinear", crea1.AdID) - assert.Nil(t, crea1.Linear) - assert.Nil(t, crea1.CompanionAds) - if assert.NotNil(t, crea1.NonLinearAds) { - nonlin := crea1.NonLinearAds - if assert.Len(t, nonlin.TrackingEvents, 5) { - assert.Equal(t, nonlin.TrackingEvents[0].Event, "creativeView") - assert.Equal(t, nonlin.TrackingEvents[0].URI, "http://myTrackingURL/nonlinear/creativeView") - assert.Equal(t, nonlin.TrackingEvents[1].Event, "expand") - assert.Equal(t, nonlin.TrackingEvents[1].URI, "http://myTrackingURL/nonlinear/expand") - } - if assert.Len(t, nonlin.NonLinears, 2) { - assert.Equal(t, "image/jpeg", nonlin.NonLinears[0].StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/50x300_static.jpg", strings.TrimSpace(nonlin.NonLinears[0].StaticResource.URI)) - assert.Equal(t, "image/jpeg", nonlin.NonLinears[1].StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/50x450_static.jpg", strings.TrimSpace(nonlin.NonLinears[1].StaticResource.URI)) - assert.Equal(t, "http://www.tremormedia.com", strings.TrimSpace(nonlin.NonLinears[1].NonLinearClickThrough)) - } - } - - crea2 := inline.Creatives[1] - assert.Equal(t, "602678-Companion", crea2.AdID) - assert.Nil(t, crea2.NonLinearAds) - assert.Nil(t, crea2.Linear) - if assert.NotNil(t, crea2.CompanionAds) { - if assert.Len(t, crea2.CompanionAds.Companions, 2) { - comp1 := crea2.CompanionAds.Companions[0] - assert.Equal(t, 300, comp1.Width) - assert.Equal(t, 250, comp1.Height) - if assert.NotNil(t, comp1.StaticResource) { - assert.Equal(t, "application/x-shockwave-flash", comp1.StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf", comp1.StaticResource.URI) - } - assert.Equal(t, "http://www.tremormedia.com", comp1.CompanionClickThrough) - - comp2 := crea2.CompanionAds.Companions[1] - assert.Equal(t, 728, comp2.Width) - assert.Equal(t, 90, comp2.Height) - if assert.NotNil(t, comp2.StaticResource) { - assert.Equal(t, "image/jpeg", comp2.StaticResource.CreativeType) - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg", comp2.StaticResource.URI) - } - if assert.Len(t, comp2.TrackingEvents, 1) { - assert.Equal(t, "creativeView", comp2.TrackingEvents[0].Event) - assert.Equal(t, "http://myTrackingURL/secondCompanion", comp2.TrackingEvents[0].URI) - } - assert.Equal(t, "http://www.tremormedia.com", comp2.CompanionClickThrough) - } - } - } - } - } -} - -func TestWrapperLinear(t *testing.T) { - v, err := loadFixture("testdata/vast_wrapper_linear_1.xml") - if !assert.NoError(t, err) { - return - } - - assert.Equal(t, "2.0", v.Version) - if assert.Len(t, v.Ads, 1) { - ad := v.Ads[0] - assert.Equal(t, "602833", ad.ID) - assert.Equal(t, 0, ad.Sequence) - assert.Nil(t, ad.InLine) - if assert.NotNil(t, ad.Wrapper) { - wrapper := ad.Wrapper - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml", wrapper.VASTAdTagURI) - assert.Equal(t, "Acudeo Compatible", wrapper.AdSystem.Name) - if assert.Len(t, wrapper.Error, 1) { - assert.Equal(t, "http://myErrorURL/wrapper/error", wrapper.Error[0].URI) - } - if assert.Len(t, wrapper.Impressions, 1) { - assert.Equal(t, "http://myTrackingURL/wrapper/impression", wrapper.Impressions[0].URI) - } - - if assert.Len(t, wrapper.Creatives, 3) { - crea1 := wrapper.Creatives[0] - assert.Equal(t, "602833", crea1.AdID) - assert.Nil(t, crea1.NonLinearAds) - assert.Nil(t, crea1.CompanionAds) - if assert.NotNil(t, crea1.Linear) { - linear := crea1.Linear - if assert.Len(t, linear.TrackingEvents, 11) { - assert.Equal(t, linear.TrackingEvents[0].Event, "creativeView") - assert.Equal(t, linear.TrackingEvents[0].URI, "http://myTrackingURL/wrapper/creativeView") - assert.Equal(t, linear.TrackingEvents[1].Event, "start") - assert.Equal(t, linear.TrackingEvents[1].URI, "http://myTrackingURL/wrapper/start") - } - assert.Nil(t, linear.VideoClicks) - } - - crea2 := wrapper.Creatives[1] - assert.Equal(t, "", crea2.AdID) - assert.Nil(t, crea2.CompanionAds) - assert.Nil(t, crea2.NonLinearAds) - if assert.NotNil(t, crea2.Linear) { - if assert.Len(t, crea2.Linear.VideoClicks.ClickTrackings, 1) { - assert.Equal(t, "http://myTrackingURL/wrapper/click", crea2.Linear.VideoClicks.ClickTrackings[0].URI) - } - } - - crea3 := wrapper.Creatives[2] - assert.Equal(t, "602833-NonLinearTracking", crea3.AdID) - assert.Nil(t, crea3.CompanionAds) - assert.Nil(t, crea3.Linear) - if assert.NotNil(t, crea3.NonLinearAds) { - if assert.Len(t, crea3.NonLinearAds.TrackingEvents, 1) { - assert.Equal(t, "creativeView", crea3.NonLinearAds.TrackingEvents[0].Event) - assert.Equal(t, "http://myTrackingURL/wrapper/creativeView", crea3.NonLinearAds.TrackingEvents[0].URI) - } - } - } - } - } -} + DescribeTable("parse", + func(fixture string, exp *VAST) { + f, err := os.Open(fixture) + Expect(err).NotTo(HaveOccurred()) + defer f.Close() -func TestWrapperNonLinear(t *testing.T) { - v, err := loadFixture("testdata/vast_wrapper_nonlinear_1.xml") - if !assert.NoError(t, err) { - return - } + var v VAST + err = xml.NewDecoder(f).Decode(&v) + Expect(err).NotTo(HaveOccurred()) + Expect(v).To(Equal(*exp)) + }, + PEntry("inline linear", "testdata/vast_inline_linear.xml", &VAST{}), + PEntry("inline nonlinear", "testdata/vast_inline_nonlinear.xml", &VAST{}), + PEntry("wrapper linear", "testdata/vast_wrapper_linear_1.xml", &VAST{}), + PEntry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{}), + ) - assert.Equal(t, "2.0", v.Version) - if assert.Len(t, v.Ads, 1) { - ad := v.Ads[0] - assert.Equal(t, "602867", ad.ID) - assert.Equal(t, 0, ad.Sequence) - assert.Nil(t, ad.InLine) - if assert.NotNil(t, ad.Wrapper) { - wrapper := ad.Wrapper - assert.Equal(t, "http://demo.tremormedia.com/proddev/vast/vast_inline_nonlinear2.xml", wrapper.VASTAdTagURI) - assert.Equal(t, "Acudeo Compatible", wrapper.AdSystem.Name) - if assert.Len(t, wrapper.Error, 1) { - assert.Equal(t, "http://myErrorURL/wrapper/error", wrapper.Error[0].URI) - } - if assert.Len(t, wrapper.Impressions, 1) { - assert.Equal(t, "http://myTrackingURL/wrapper/impression", wrapper.Impressions[0].URI) - } +}) - if assert.Len(t, wrapper.Creatives, 2) { - crea1 := wrapper.Creatives[0] - assert.Equal(t, "602867", crea1.AdID) - assert.Nil(t, crea1.NonLinearAds) - assert.Nil(t, crea1.CompanionAds) - assert.NotNil(t, crea1.Linear) +// -------------------------------------------------------------------- - crea2 := wrapper.Creatives[1] - assert.Equal(t, "602867-NonLinearTracking", crea2.AdID) - assert.Nil(t, crea2.CompanionAds) - assert.Nil(t, crea2.Linear) - if assert.NotNil(t, crea2.NonLinearAds) { - if assert.Len(t, crea2.NonLinearAds.TrackingEvents, 5) { - assert.Equal(t, "creativeView", crea2.NonLinearAds.TrackingEvents[0].Event) - assert.Equal(t, "http://myTrackingURL/wrapper/nonlinear/creativeView/creativeView", crea2.NonLinearAds.TrackingEvents[0].URI) - } - } - } - } - } +func TestSuite(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "vast") } From 54debad92810ce7c091071f9da3b5dd8d10f4cdc Mon Sep 17 00:00:00 2001 From: Dimitrij Denissenko Date: Tue, 14 Feb 2017 18:38:04 +0000 Subject: [PATCH 2/8] First test --- offset_test.go | 5 ++- vast_test.go | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/offset_test.go b/offset_test.go index 33b9e60..b2a935c 100644 --- a/offset_test.go +++ b/offset_test.go @@ -7,7 +7,6 @@ import ( ) var _ = Describe("Offset", func() { - zero := Duration(0) DescribeTable("marshal", func(o *Offset, exp string) { @@ -17,7 +16,7 @@ var _ = Describe("Offset", func() { }, Entry("0%", &Offset{}, "0%"), Entry("10%", &Offset{Percent: 0.1}, "10%"), - Entry("00:00:00", &Offset{Duration: &zero}, "00:00:00"), + Entry("00:00:00", &Offset{Duration: durationPtr(0)}, "00:00:00"), ) DescribeTable("unmarshal", @@ -29,7 +28,7 @@ var _ = Describe("Offset", func() { }, Entry("0%", "0%", 0.0, nil), Entry("10%", "10%", 0.1, nil), - Entry("00:00:00", "00:00:00", 0.0, &zero), + Entry("00:00:00", "00:00:00", 0.0, durationPtr(0)), ) It("should fail to unmarshal bad inputs", func() { diff --git a/vast_test.go b/vast_test.go index 19f1fd3..9ab7d54 100644 --- a/vast_test.go +++ b/vast_test.go @@ -4,6 +4,7 @@ import ( "encoding/xml" "os" "testing" + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" @@ -13,17 +14,92 @@ import ( var _ = Describe("VAST", func() { DescribeTable("parse", + func(fixture string, exp *VAST) { f, err := os.Open(fixture) Expect(err).NotTo(HaveOccurred()) defer f.Close() var v VAST - err = xml.NewDecoder(f).Decode(&v) - Expect(err).NotTo(HaveOccurred()) + Expect(xml.NewDecoder(f).Decode(&v)).To(Succeed()) Expect(v).To(Equal(*exp)) }, - PEntry("inline linear", "testdata/vast_inline_linear.xml", &VAST{}), + + Entry("inline linear", "testdata/vast_inline_linear.xml", &VAST{ + Version: "2.0", + Ads: []Ad{{ + ID: "601364", + InLine: &InLine{ + AdSystem: &AdSystem{Version: "1.0", Name: "Acudeo Compatible"}, + AdTitle: &AdTitle{Name: "VAST 2.0 Instream Test 1"}, + Impressions: []Impression{ + {URI: "http://myTrackingURL/impression"}, + {ID: "foo", URI: "http://myTrackingURL/impression2"}, + }, + Creatives: []Creative{ + { + AdID: "601364", + Linear: &Linear{ + Duration: durationPtr(30 * time.Second), + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: "http://myTrackingURL/creativeView"}, + {Event: "start", URI: "http://myTrackingURL/start"}, + {Event: "midpoint", URI: "http://myTrackingURL/midpoint"}, + {Event: "firstQuartile", URI: "http://myTrackingURL/firstQuartile"}, + {Event: "thirdQuartile", URI: "http://myTrackingURL/thirdQuartile"}, + {Event: "complete", URI: "http://myTrackingURL/complete"}, + }, + VideoClicks: &VideoClicks{ + ClickThroughs: []VideoClick{{URI: "http://www.tremormedia.com"}}, + ClickTrackings: []VideoClick{{URI: "http://myTrackingURL/click"}}, + }, + MediaFiles: []MediaFile{ + { + Delivery: "progressive", + Type: "video/x-flv", + Bitrate: 500, + Width: 400, + Height: 300, + Scalable: true, + MaintainAspectRatio: true, + URI: "http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv", + }, + }, + }, + }, + { + AdID: "601364-Companion", + CompanionAds: &CompanionAds{ + Required: "all", + Companions: []Companion{ + { + Width: 300, + Height: 250, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/Blistex1.jpg"}, + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: "http://myTrackingURL/firstCompanionCreativeView"}, + }, + }, + { + Width: 728, + Height: 90, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg"}, + }, + }, + }, + }, + }, + Description: "VAST 2.0 Instream Test 1", + Error: []Error{ + {URI: "http://myErrorURL/error"}, + {URI: "http://myErrorURL/error2"}, + }, + }, + }}, + }), + PEntry("inline nonlinear", "testdata/vast_inline_nonlinear.xml", &VAST{}), PEntry("wrapper linear", "testdata/vast_wrapper_linear_1.xml", &VAST{}), PEntry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{}), @@ -37,3 +113,8 @@ func TestSuite(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "vast") } + +func durationPtr(d time.Duration) *Duration { + v := Duration(d) + return &v +} From d920022dc06d33be7a5f0811a084cb0ebf7c7d3b Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 12:38:10 +0000 Subject: [PATCH 3/8] Added test for vast_inline_nonlinear.xml --- vast_test.go | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/vast_test.go b/vast_test.go index 9ab7d54..18f884b 100644 --- a/vast_test.go +++ b/vast_test.go @@ -100,7 +100,88 @@ var _ = Describe("VAST", func() { }}, }), - PEntry("inline nonlinear", "testdata/vast_inline_nonlinear.xml", &VAST{}), + Entry("inline nonlinear", "testdata/vast_inline_nonlinear.xml", &VAST{ + Version: "2.0", + Ads: []Ad{ + { + ID: "602678", + InLine: &InLine{ + AdSystem: &AdSystem{Name: "Acudeo Compatible"}, + AdTitle: &AdTitle{Name: "NonLinear Test Campaign 1"}, + Description: "NonLinear Test Campaign 1", + Survey: "http://mySurveyURL/survey", + Error: []Error{{URI: "http://myErrorURL/error"}}, + Impressions: []Impression{{URI: "http://myTrackingURL/impression"}}, + Creatives: []Creative{ + { + AdID: "602678-NonLinear", + NonLinearAds: &NonLinearAds{ + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: "http://myTrackingURL/nonlinear/creativeView"}, + {Event: "expand", URI: "http://myTrackingURL/nonlinear/expand"}, + {Event: "collapse", URI: "http://myTrackingURL/nonlinear/collapse"}, + {Event: "acceptInvitation", URI: "http://myTrackingURL/nonlinear/acceptInvitation"}, + {Event: "close", URI: "http://myTrackingURL/nonlinear/close"}, + }, + NonLinears: []NonLinear{ + { + Height: 50, + Width: 300, + MinSuggestedDuration: durationPtr(15 * time.Second), + StaticResource: &StaticResource{ + CreativeType: "image/jpeg", + // TODO: Normalize these URIs + URI: "\n\t\t\t\t\thttp://demo.tremormedia.com/proddev/vast/50x300_static.jpg\n\t\t\t\t\t", + }, + NonLinearClickThrough: "http://www.tremormedia.com", + }, + { + Height: 50, + Width: 450, + MinSuggestedDuration: durationPtr(20 * time.Second), + StaticResource: &StaticResource{ + CreativeType: "image/jpeg", + // TODO: Normalize these URIs + URI: "\n\t\t\t\t\thttp://demo.tremormedia.com/proddev/vast/50x450_static.jpg\n\t\t\t\t\t", + }, + NonLinearClickThrough: "http://www.tremormedia.com", + }, + }, + }, + }, + { + AdID: "602678-Companion", + CompanionAds: &CompanionAds{ + Companions: []Companion{ + { + Width: 300, + Height: 250, + StaticResource: &StaticResource{ + CreativeType: "application/x-shockwave-flash", + URI: "http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf", + }, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + }, + { + Width: 728, + Height: 90, + StaticResource: &StaticResource{ + CreativeType: "image/jpeg", + URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg", + }, + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: "http://myTrackingURL/secondCompanion"}, + }, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + }, + }, + }, + }, + }, + }, + }, + }, + }), PEntry("wrapper linear", "testdata/vast_wrapper_linear_1.xml", &VAST{}), PEntry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{}), ) From bd12086077983fea256869cd2c1ff3627832a2bc Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 14:48:50 +0000 Subject: [PATCH 4/8] Added URIString to help normalize URIs --- uri_string.go | 17 +++++++++++++++++ uri_string_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 uri_string.go create mode 100644 uri_string_test.go diff --git a/uri_string.go b/uri_string.go new file mode 100644 index 0000000..375b3fc --- /dev/null +++ b/uri_string.go @@ -0,0 +1,17 @@ +package vast + +import "strings" + +// URIString is a string that allows for stripping of whitespace when Unmarshalled +type URIString string + +// MarshalText implements the encoding.TextMarshaler interface. +func (s URIString) MarshalText() ([]byte, error) { + return []byte(s), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (s *URIString) UnmarshalText(data []byte) error { + *s = URIString(strings.TrimSpace(string(data))) + return nil +} diff --git a/uri_string_test.go b/uri_string_test.go new file mode 100644 index 0000000..18726db --- /dev/null +++ b/uri_string_test.go @@ -0,0 +1,33 @@ +package vast + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/gomega" +) + +var _ = Describe("URIString", func() { + + DescribeTable("marshal", + func(d URIString, exp string) { + b, err := d.MarshalText() + Expect(err).NotTo(HaveOccurred()) + Expect(string(b)).To(Equal(exp)) + }, + Entry("", URIString(""), ""), + Entry("http://example.com", URIString("http://example.com"), "http://example.com"), + ) + + DescribeTable("unmarshal", + func(s string, exp URIString) { + d := new(URIString) + Expect(d.UnmarshalText([]byte(s))).To(Succeed()) + Expect(*d).To(Equal(exp)) + }, + Entry("Blank", "", URIString("")), + Entry("Whitespace only", "\n\t ", URIString("")), + Entry("Ideal Example", "http://example.com", URIString("http://example.com")), + Entry("Real-world Example", "\n\t\t\t http://example.com \n\t\t\t", URIString("http://example.com")), + ) + +}) From 68d33064fa18dc1a4033deec23cb40983463772f Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 14:51:06 +0000 Subject: [PATCH 5/8] Implemented URIString, cleaning up parsed URIs --- vast.go | 24 +++++++++---------- vast_test.go | 66 +++++++++++++++++++++++++--------------------------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/vast.go b/vast.go index 0e81190..d3ea558 100644 --- a/vast.go +++ b/vast.go @@ -110,14 +110,14 @@ type InLine struct { } type Error struct { - URI string `xml:",cdata"` + URI URIString `xml:",cdata"` } // Impression is a URI that directs the video player to a tracking resource file that // the video player should request when the first frame of the ad is displayed type Impression struct { - ID string `xml:"id,attr,omitempty"` - URI string `xml:",cdata"` + ID string `xml:"id,attr,omitempty"` + URI URIString `xml:",cdata"` } // Pricing provides a value that represents a price that can be used by real-time @@ -146,7 +146,7 @@ type Wrapper struct { // The name of the ad server that returned the ad AdSystem *AdSystem // URL of ad tag of downstream Secondary Ad Server - VASTAdTagURI string + VASTAdTagURI URIString // One or more URIs that directs the video player to a tracking resource file that the // video player should request when the first frame of the ad is displayed Impressions []Impression `xml:"Impression"` @@ -460,8 +460,8 @@ type Tracking struct { Event string `xml:"event,attr"` // The time during the video at which this url should be pinged. Must be present for // progress event. Must match (\d{2}:[0-5]\d:[0-5]\d(\.\d\d\d)?|1?\d?\d(\.?\d)*%) - Offset *Offset `xml:"offset,attr,omitempty"` - URI string `xml:",cdata"` + Offset *Offset `xml:"offset,attr,omitempty"` + URI URIString `xml:",cdata"` } // StaticResource is the URL to a static file, such as an image or SWF file @@ -469,7 +469,7 @@ type StaticResource struct { // Mime type of static resource CreativeType string `xml:"creativeType,attr,omitempty"` // URL to a static file, such as an image or SWF file - URI string `xml:",cdata"` + URI URIString `xml:",cdata"` } // HTMLResource is a container for HTML data @@ -495,8 +495,8 @@ type VideoClicks struct { // VideoClick defines a click URL for a linear creative type VideoClick struct { - ID string `xml:"id,attr,omitempty"` - URI string `xml:",cdata"` + ID string `xml:"id,attr,omitempty"` + URI URIString `xml:",cdata"` } // MediaFile defines a reference to a linear creative asset @@ -533,8 +533,8 @@ type MediaFile struct { // is interactive. Suggested values for this element are “VPAID”, “FlashVars” // (for Flash/Flex), “initParams” (for Silverlight) and “GetVariables” (variables // placed in key/value pairs on the asset request). - APIFramework string `xml:"apiFramework,attr,omitempty"` - URI string `xml:",cdata"` + APIFramework string `xml:"apiFramework,attr,omitempty"` + URI URIString `xml:",cdata"` } // Extensions defines extensions @@ -554,5 +554,5 @@ type Extension struct { type CompanionClickThrough struct { // URL to a static file, such as an image or SWF file - URI string `xml:",cdata"` + URI URIString `xml:",cdata"` } diff --git a/vast_test.go b/vast_test.go index 18f884b..48e9864 100644 --- a/vast_test.go +++ b/vast_test.go @@ -33,8 +33,8 @@ var _ = Describe("VAST", func() { AdSystem: &AdSystem{Version: "1.0", Name: "Acudeo Compatible"}, AdTitle: &AdTitle{Name: "VAST 2.0 Instream Test 1"}, Impressions: []Impression{ - {URI: "http://myTrackingURL/impression"}, - {ID: "foo", URI: "http://myTrackingURL/impression2"}, + {URI: URIString("http://myTrackingURL/impression")}, + {ID: "foo", URI: URIString("http://myTrackingURL/impression2")}, }, Creatives: []Creative{ { @@ -42,16 +42,16 @@ var _ = Describe("VAST", func() { Linear: &Linear{ Duration: durationPtr(30 * time.Second), TrackingEvents: []Tracking{ - {Event: "creativeView", URI: "http://myTrackingURL/creativeView"}, - {Event: "start", URI: "http://myTrackingURL/start"}, - {Event: "midpoint", URI: "http://myTrackingURL/midpoint"}, - {Event: "firstQuartile", URI: "http://myTrackingURL/firstQuartile"}, - {Event: "thirdQuartile", URI: "http://myTrackingURL/thirdQuartile"}, - {Event: "complete", URI: "http://myTrackingURL/complete"}, + {Event: "creativeView", URI: URIString("http://myTrackingURL/creativeView")}, + {Event: "start", URI: URIString("http://myTrackingURL/start")}, + {Event: "midpoint", URI: URIString("http://myTrackingURL/midpoint")}, + {Event: "firstQuartile", URI: URIString("http://myTrackingURL/firstQuartile")}, + {Event: "thirdQuartile", URI: URIString("http://myTrackingURL/thirdQuartile")}, + {Event: "complete", URI: URIString("http://myTrackingURL/complete")}, }, VideoClicks: &VideoClicks{ - ClickThroughs: []VideoClick{{URI: "http://www.tremormedia.com"}}, - ClickTrackings: []VideoClick{{URI: "http://myTrackingURL/click"}}, + ClickThroughs: []VideoClick{{URI: URIString("http://www.tremormedia.com")}}, + ClickTrackings: []VideoClick{{URI: URIString("http://myTrackingURL/click")}}, }, MediaFiles: []MediaFile{ { @@ -62,7 +62,7 @@ var _ = Describe("VAST", func() { Height: 300, Scalable: true, MaintainAspectRatio: true, - URI: "http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv", + URI: URIString("http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv"), }, }, }, @@ -75,17 +75,17 @@ var _ = Describe("VAST", func() { { Width: 300, Height: 250, - CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, - StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/Blistex1.jpg"}, + CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: URIString("http://demo.tremormedia.com/proddev/vast/Blistex1.jpg")}, TrackingEvents: []Tracking{ - {Event: "creativeView", URI: "http://myTrackingURL/firstCompanionCreativeView"}, + {Event: "creativeView", URI: URIString("http://myTrackingURL/firstCompanionCreativeView")}, }, }, { Width: 728, Height: 90, - CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, - StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg"}, + CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: URIString("http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg")}, }, }, }, @@ -93,8 +93,8 @@ var _ = Describe("VAST", func() { }, Description: "VAST 2.0 Instream Test 1", Error: []Error{ - {URI: "http://myErrorURL/error"}, - {URI: "http://myErrorURL/error2"}, + {URI: URIString("http://myErrorURL/error")}, + {URI: URIString("http://myErrorURL/error2")}, }, }, }}, @@ -110,18 +110,18 @@ var _ = Describe("VAST", func() { AdTitle: &AdTitle{Name: "NonLinear Test Campaign 1"}, Description: "NonLinear Test Campaign 1", Survey: "http://mySurveyURL/survey", - Error: []Error{{URI: "http://myErrorURL/error"}}, - Impressions: []Impression{{URI: "http://myTrackingURL/impression"}}, + Error: []Error{{URI: URIString("http://myErrorURL/error")}}, + Impressions: []Impression{{URI: URIString("http://myTrackingURL/impression")}}, Creatives: []Creative{ { AdID: "602678-NonLinear", NonLinearAds: &NonLinearAds{ TrackingEvents: []Tracking{ - {Event: "creativeView", URI: "http://myTrackingURL/nonlinear/creativeView"}, - {Event: "expand", URI: "http://myTrackingURL/nonlinear/expand"}, - {Event: "collapse", URI: "http://myTrackingURL/nonlinear/collapse"}, - {Event: "acceptInvitation", URI: "http://myTrackingURL/nonlinear/acceptInvitation"}, - {Event: "close", URI: "http://myTrackingURL/nonlinear/close"}, + {Event: "creativeView", URI: URIString("http://myTrackingURL/nonlinear/creativeView")}, + {Event: "expand", URI: URIString("http://myTrackingURL/nonlinear/expand")}, + {Event: "collapse", URI: URIString("http://myTrackingURL/nonlinear/collapse")}, + {Event: "acceptInvitation", URI: URIString("http://myTrackingURL/nonlinear/acceptInvitation")}, + {Event: "close", URI: URIString("http://myTrackingURL/nonlinear/close")}, }, NonLinears: []NonLinear{ { @@ -130,8 +130,7 @@ var _ = Describe("VAST", func() { MinSuggestedDuration: durationPtr(15 * time.Second), StaticResource: &StaticResource{ CreativeType: "image/jpeg", - // TODO: Normalize these URIs - URI: "\n\t\t\t\t\thttp://demo.tremormedia.com/proddev/vast/50x300_static.jpg\n\t\t\t\t\t", + URI: URIString("http://demo.tremormedia.com/proddev/vast/50x300_static.jpg"), }, NonLinearClickThrough: "http://www.tremormedia.com", }, @@ -141,8 +140,7 @@ var _ = Describe("VAST", func() { MinSuggestedDuration: durationPtr(20 * time.Second), StaticResource: &StaticResource{ CreativeType: "image/jpeg", - // TODO: Normalize these URIs - URI: "\n\t\t\t\t\thttp://demo.tremormedia.com/proddev/vast/50x450_static.jpg\n\t\t\t\t\t", + URI: URIString("http://demo.tremormedia.com/proddev/vast/50x450_static.jpg"), }, NonLinearClickThrough: "http://www.tremormedia.com", }, @@ -158,21 +156,21 @@ var _ = Describe("VAST", func() { Height: 250, StaticResource: &StaticResource{ CreativeType: "application/x-shockwave-flash", - URI: "http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf", + URI: URIString("http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf"), }, - CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, }, { Width: 728, Height: 90, StaticResource: &StaticResource{ CreativeType: "image/jpeg", - URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg", + URI: URIString("http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg"), }, TrackingEvents: []Tracking{ - {Event: "creativeView", URI: "http://myTrackingURL/secondCompanion"}, + {Event: "creativeView", URI: URIString("http://myTrackingURL/secondCompanion")}, }, - CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, }, }, }, From ef35108f70e92510611af44817ec5c89f2f94e0b Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 15:26:10 +0000 Subject: [PATCH 6/8] Added `wrapper linear` test --- vast_test.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/vast_test.go b/vast_test.go index 48e9864..d7f2ccb 100644 --- a/vast_test.go +++ b/vast_test.go @@ -180,7 +180,57 @@ var _ = Describe("VAST", func() { }, }, }), - PEntry("wrapper linear", "testdata/vast_wrapper_linear_1.xml", &VAST{}), + + Entry("wrapper linear", "testdata/vast_wrapper_linear_1.xml", &VAST{ + Version: "2.0", + Ads: []Ad{ + { + ID: "602833", + Wrapper: &Wrapper{ + AdSystem: &AdSystem{Name: "Acudeo Compatible"}, + VASTAdTagURI: URIString("http://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml"), + Error: []Error{{URI: URIString("http://myErrorURL/wrapper/error")}}, + Impressions: []Impression{{URI: URIString("http://myTrackingURL/wrapper/impression")}}, + Creatives: []CreativeWrapper{ + { + AdID: "602833", + Linear: &LinearWrapper{ + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/creativeView")}, + {Event: "start", URI: URIString("http://myTrackingURL/wrapper/start")}, + {Event: "midpoint", URI: URIString("http://myTrackingURL/wrapper/midpoint")}, + {Event: "firstQuartile", URI: URIString("http://myTrackingURL/wrapper/firstQuartile")}, + {Event: "thirdQuartile", URI: URIString("http://myTrackingURL/wrapper/thirdQuartile")}, + {Event: "complete", URI: URIString("http://myTrackingURL/wrapper/complete")}, + {Event: "mute", URI: URIString("http://myTrackingURL/wrapper/mute")}, + {Event: "unmute", URI: URIString("http://myTrackingURL/wrapper/unmute")}, + {Event: "pause", URI: URIString("http://myTrackingURL/wrapper/pause")}, + {Event: "resume", URI: URIString("http://myTrackingURL/wrapper/resume")}, + {Event: "fullscreen", URI: URIString("http://myTrackingURL/wrapper/fullscreen")}, + }, + }, + }, + { + Linear: &LinearWrapper{ + VideoClicks: &VideoClicks{ + ClickTrackings: []VideoClick{{URI: URIString("http://myTrackingURL/wrapper/click")}}, + }, + }, + }, + { + AdID: "602833-NonLinearTracking", + NonLinearAds: &NonLinearAdsWrapper{ + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/creativeView")}, + }, + }, + }, + }, + }, + }, + }, + }), + PEntry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{}), ) From 167a5092a621a1391802e23eab9bfd0a7ed9f725 Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 15:48:54 +0000 Subject: [PATCH 7/8] Added test for Extensions --- testdata/vast_inline_linear.xml | 8 ++++++ vast_test.go | 45 ++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/testdata/vast_inline_linear.xml b/testdata/vast_inline_linear.xml index a0900c6..8947a39 100644 --- a/testdata/vast_inline_linear.xml +++ b/testdata/vast_inline_linear.xml @@ -46,6 +46,14 @@ + + + + US + CA + + + diff --git a/vast_test.go b/vast_test.go index d7f2ccb..2f02ec8 100644 --- a/vast_test.go +++ b/vast_test.go @@ -96,6 +96,18 @@ var _ = Describe("VAST", func() { {URI: URIString("http://myErrorURL/error")}, {URI: URIString("http://myErrorURL/error2")}, }, + Extensions: &Extensions{ + Extensions: []Extension{ + { + Data: []byte(` + + US + CA + + `), + }, + }, + }, }, }}, }), @@ -231,7 +243,38 @@ var _ = Describe("VAST", func() { }, }), - PEntry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{}), + Entry("wrapper nonlinear", "testdata/vast_wrapper_nonlinear_1.xml", &VAST{ + Version: "2.0", + Ads: []Ad{ + { + ID: "602867", + Wrapper: &Wrapper{ + AdSystem: &AdSystem{Name: "Acudeo Compatible"}, + VASTAdTagURI: URIString("http://demo.tremormedia.com/proddev/vast/vast_inline_nonlinear2.xml"), + Error: []Error{{URI: URIString("http://myErrorURL/wrapper/error")}}, + Impressions: []Impression{{URI: URIString("http://myTrackingURL/wrapper/impression")}}, + Creatives: []CreativeWrapper{ + { + AdID: "602867", + Linear: &LinearWrapper{}, + }, + { + AdID: "602867-NonLinearTracking", + NonLinearAds: &NonLinearAdsWrapper{ + TrackingEvents: []Tracking{ + {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/creativeView")}, + {Event: "expand", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/expand")}, + {Event: "collapse", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/collapse")}, + {Event: "acceptInvitation", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/acceptInvitation")}, + {Event: "close", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/close")}, + }, + }, + }, + }, + }, + }, + }, + }), ) }) From 037d7eee99d382b5bcb1fa2824583bcfab31b696 Mon Sep 17 00:00:00 2001 From: Alex Neill Date: Wed, 15 Feb 2017 16:27:34 +0000 Subject: [PATCH 8/8] Review changes - Renamed `URIString` to `URI` - Using `bytes.TrimSpace` instead of `strings.TrimSpace` in `URI.Unmarshal` - Removing the unnecessary wrapping of URIs in tests --- uri.go | 17 +++++++ uri_string.go | 17 ------- uri_string_test.go | 33 ------------- uri_test.go | 33 +++++++++++++ vast.go | 24 +++++----- vast_test.go | 112 ++++++++++++++++++++++----------------------- 6 files changed, 118 insertions(+), 118 deletions(-) create mode 100644 uri.go delete mode 100644 uri_string.go delete mode 100644 uri_string_test.go create mode 100644 uri_test.go diff --git a/uri.go b/uri.go new file mode 100644 index 0000000..4978eeb --- /dev/null +++ b/uri.go @@ -0,0 +1,17 @@ +package vast + +import "bytes" + +// URI is a string that allows for stripping of whitespace when Unmarshalled +type URI string + +// MarshalText implements the encoding.TextMarshaler interface. +func (s URI) MarshalText() ([]byte, error) { + return []byte(s), nil +} + +// UnmarshalText implements the encoding.TextUnmarshaler interface. +func (s *URI) UnmarshalText(data []byte) error { + *s = URI(bytes.TrimSpace(data)) + return nil +} diff --git a/uri_string.go b/uri_string.go deleted file mode 100644 index 375b3fc..0000000 --- a/uri_string.go +++ /dev/null @@ -1,17 +0,0 @@ -package vast - -import "strings" - -// URIString is a string that allows for stripping of whitespace when Unmarshalled -type URIString string - -// MarshalText implements the encoding.TextMarshaler interface. -func (s URIString) MarshalText() ([]byte, error) { - return []byte(s), nil -} - -// UnmarshalText implements the encoding.TextUnmarshaler interface. -func (s *URIString) UnmarshalText(data []byte) error { - *s = URIString(strings.TrimSpace(string(data))) - return nil -} diff --git a/uri_string_test.go b/uri_string_test.go deleted file mode 100644 index 18726db..0000000 --- a/uri_string_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package vast - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/ginkgo/extensions/table" - . "github.com/onsi/gomega" -) - -var _ = Describe("URIString", func() { - - DescribeTable("marshal", - func(d URIString, exp string) { - b, err := d.MarshalText() - Expect(err).NotTo(HaveOccurred()) - Expect(string(b)).To(Equal(exp)) - }, - Entry("", URIString(""), ""), - Entry("http://example.com", URIString("http://example.com"), "http://example.com"), - ) - - DescribeTable("unmarshal", - func(s string, exp URIString) { - d := new(URIString) - Expect(d.UnmarshalText([]byte(s))).To(Succeed()) - Expect(*d).To(Equal(exp)) - }, - Entry("Blank", "", URIString("")), - Entry("Whitespace only", "\n\t ", URIString("")), - Entry("Ideal Example", "http://example.com", URIString("http://example.com")), - Entry("Real-world Example", "\n\t\t\t http://example.com \n\t\t\t", URIString("http://example.com")), - ) - -}) diff --git a/uri_test.go b/uri_test.go new file mode 100644 index 0000000..673bab2 --- /dev/null +++ b/uri_test.go @@ -0,0 +1,33 @@ +package vast + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/ginkgo/extensions/table" + . "github.com/onsi/gomega" +) + +var _ = Describe("URI", func() { + + DescribeTable("marshal", + func(d URI, exp string) { + b, err := d.MarshalText() + Expect(err).NotTo(HaveOccurred()) + Expect(string(b)).To(Equal(exp)) + }, + Entry("", URI(""), ""), + Entry("http://example.com", URI("http://example.com"), "http://example.com"), + ) + + DescribeTable("unmarshal", + func(s string, exp URI) { + d := new(URI) + Expect(d.UnmarshalText([]byte(s))).To(Succeed()) + Expect(*d).To(Equal(exp)) + }, + Entry("Blank", "", URI("")), + Entry("Whitespace only", "\n\t ", URI("")), + Entry("Ideal Example", "http://example.com", URI("http://example.com")), + Entry("Real-world Example", "\n\t\t\t http://example.com \n\t\t\t", URI("http://example.com")), + ) + +}) diff --git a/vast.go b/vast.go index d3ea558..aee4a34 100644 --- a/vast.go +++ b/vast.go @@ -110,14 +110,14 @@ type InLine struct { } type Error struct { - URI URIString `xml:",cdata"` + URI URI `xml:",cdata"` } // Impression is a URI that directs the video player to a tracking resource file that // the video player should request when the first frame of the ad is displayed type Impression struct { - ID string `xml:"id,attr,omitempty"` - URI URIString `xml:",cdata"` + ID string `xml:"id,attr,omitempty"` + URI URI `xml:",cdata"` } // Pricing provides a value that represents a price that can be used by real-time @@ -146,7 +146,7 @@ type Wrapper struct { // The name of the ad server that returned the ad AdSystem *AdSystem // URL of ad tag of downstream Secondary Ad Server - VASTAdTagURI URIString + VASTAdTagURI URI // One or more URIs that directs the video player to a tracking resource file that the // video player should request when the first frame of the ad is displayed Impressions []Impression `xml:"Impression"` @@ -460,8 +460,8 @@ type Tracking struct { Event string `xml:"event,attr"` // The time during the video at which this url should be pinged. Must be present for // progress event. Must match (\d{2}:[0-5]\d:[0-5]\d(\.\d\d\d)?|1?\d?\d(\.?\d)*%) - Offset *Offset `xml:"offset,attr,omitempty"` - URI URIString `xml:",cdata"` + Offset *Offset `xml:"offset,attr,omitempty"` + URI URI `xml:",cdata"` } // StaticResource is the URL to a static file, such as an image or SWF file @@ -469,7 +469,7 @@ type StaticResource struct { // Mime type of static resource CreativeType string `xml:"creativeType,attr,omitempty"` // URL to a static file, such as an image or SWF file - URI URIString `xml:",cdata"` + URI URI `xml:",cdata"` } // HTMLResource is a container for HTML data @@ -495,8 +495,8 @@ type VideoClicks struct { // VideoClick defines a click URL for a linear creative type VideoClick struct { - ID string `xml:"id,attr,omitempty"` - URI URIString `xml:",cdata"` + ID string `xml:"id,attr,omitempty"` + URI URI `xml:",cdata"` } // MediaFile defines a reference to a linear creative asset @@ -533,8 +533,8 @@ type MediaFile struct { // is interactive. Suggested values for this element are “VPAID”, “FlashVars” // (for Flash/Flex), “initParams” (for Silverlight) and “GetVariables” (variables // placed in key/value pairs on the asset request). - APIFramework string `xml:"apiFramework,attr,omitempty"` - URI URIString `xml:",cdata"` + APIFramework string `xml:"apiFramework,attr,omitempty"` + URI URI `xml:",cdata"` } // Extensions defines extensions @@ -554,5 +554,5 @@ type Extension struct { type CompanionClickThrough struct { // URL to a static file, such as an image or SWF file - URI URIString `xml:",cdata"` + URI URI `xml:",cdata"` } diff --git a/vast_test.go b/vast_test.go index 2f02ec8..02efee7 100644 --- a/vast_test.go +++ b/vast_test.go @@ -33,8 +33,8 @@ var _ = Describe("VAST", func() { AdSystem: &AdSystem{Version: "1.0", Name: "Acudeo Compatible"}, AdTitle: &AdTitle{Name: "VAST 2.0 Instream Test 1"}, Impressions: []Impression{ - {URI: URIString("http://myTrackingURL/impression")}, - {ID: "foo", URI: URIString("http://myTrackingURL/impression2")}, + {URI: "http://myTrackingURL/impression"}, + {ID: "foo", URI: "http://myTrackingURL/impression2"}, }, Creatives: []Creative{ { @@ -42,16 +42,16 @@ var _ = Describe("VAST", func() { Linear: &Linear{ Duration: durationPtr(30 * time.Second), TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/creativeView")}, - {Event: "start", URI: URIString("http://myTrackingURL/start")}, - {Event: "midpoint", URI: URIString("http://myTrackingURL/midpoint")}, - {Event: "firstQuartile", URI: URIString("http://myTrackingURL/firstQuartile")}, - {Event: "thirdQuartile", URI: URIString("http://myTrackingURL/thirdQuartile")}, - {Event: "complete", URI: URIString("http://myTrackingURL/complete")}, + {Event: "creativeView", URI: "http://myTrackingURL/creativeView"}, + {Event: "start", URI: "http://myTrackingURL/start"}, + {Event: "midpoint", URI: "http://myTrackingURL/midpoint"}, + {Event: "firstQuartile", URI: "http://myTrackingURL/firstQuartile"}, + {Event: "thirdQuartile", URI: "http://myTrackingURL/thirdQuartile"}, + {Event: "complete", URI: "http://myTrackingURL/complete"}, }, VideoClicks: &VideoClicks{ - ClickThroughs: []VideoClick{{URI: URIString("http://www.tremormedia.com")}}, - ClickTrackings: []VideoClick{{URI: URIString("http://myTrackingURL/click")}}, + ClickThroughs: []VideoClick{{URI: "http://www.tremormedia.com"}}, + ClickTrackings: []VideoClick{{URI: "http://myTrackingURL/click"}}, }, MediaFiles: []MediaFile{ { @@ -62,7 +62,7 @@ var _ = Describe("VAST", func() { Height: 300, Scalable: true, MaintainAspectRatio: true, - URI: URIString("http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv"), + URI: "http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv", }, }, }, @@ -75,17 +75,17 @@ var _ = Describe("VAST", func() { { Width: 300, Height: 250, - CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, - StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: URIString("http://demo.tremormedia.com/proddev/vast/Blistex1.jpg")}, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/Blistex1.jpg"}, TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/firstCompanionCreativeView")}, + {Event: "creativeView", URI: "http://myTrackingURL/firstCompanionCreativeView"}, }, }, { Width: 728, Height: 90, - CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, - StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: URIString("http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg")}, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, + StaticResource: &StaticResource{CreativeType: "image/jpeg", URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg"}, }, }, }, @@ -93,8 +93,8 @@ var _ = Describe("VAST", func() { }, Description: "VAST 2.0 Instream Test 1", Error: []Error{ - {URI: URIString("http://myErrorURL/error")}, - {URI: URIString("http://myErrorURL/error2")}, + {URI: "http://myErrorURL/error"}, + {URI: "http://myErrorURL/error2"}, }, Extensions: &Extensions{ Extensions: []Extension{ @@ -122,18 +122,18 @@ var _ = Describe("VAST", func() { AdTitle: &AdTitle{Name: "NonLinear Test Campaign 1"}, Description: "NonLinear Test Campaign 1", Survey: "http://mySurveyURL/survey", - Error: []Error{{URI: URIString("http://myErrorURL/error")}}, - Impressions: []Impression{{URI: URIString("http://myTrackingURL/impression")}}, + Error: []Error{{URI: "http://myErrorURL/error"}}, + Impressions: []Impression{{URI: "http://myTrackingURL/impression"}}, Creatives: []Creative{ { AdID: "602678-NonLinear", NonLinearAds: &NonLinearAds{ TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/nonlinear/creativeView")}, - {Event: "expand", URI: URIString("http://myTrackingURL/nonlinear/expand")}, - {Event: "collapse", URI: URIString("http://myTrackingURL/nonlinear/collapse")}, - {Event: "acceptInvitation", URI: URIString("http://myTrackingURL/nonlinear/acceptInvitation")}, - {Event: "close", URI: URIString("http://myTrackingURL/nonlinear/close")}, + {Event: "creativeView", URI: "http://myTrackingURL/nonlinear/creativeView"}, + {Event: "expand", URI: "http://myTrackingURL/nonlinear/expand"}, + {Event: "collapse", URI: "http://myTrackingURL/nonlinear/collapse"}, + {Event: "acceptInvitation", URI: "http://myTrackingURL/nonlinear/acceptInvitation"}, + {Event: "close", URI: "http://myTrackingURL/nonlinear/close"}, }, NonLinears: []NonLinear{ { @@ -142,7 +142,7 @@ var _ = Describe("VAST", func() { MinSuggestedDuration: durationPtr(15 * time.Second), StaticResource: &StaticResource{ CreativeType: "image/jpeg", - URI: URIString("http://demo.tremormedia.com/proddev/vast/50x300_static.jpg"), + URI: "http://demo.tremormedia.com/proddev/vast/50x300_static.jpg", }, NonLinearClickThrough: "http://www.tremormedia.com", }, @@ -152,7 +152,7 @@ var _ = Describe("VAST", func() { MinSuggestedDuration: durationPtr(20 * time.Second), StaticResource: &StaticResource{ CreativeType: "image/jpeg", - URI: URIString("http://demo.tremormedia.com/proddev/vast/50x450_static.jpg"), + URI: "http://demo.tremormedia.com/proddev/vast/50x450_static.jpg", }, NonLinearClickThrough: "http://www.tremormedia.com", }, @@ -168,21 +168,21 @@ var _ = Describe("VAST", func() { Height: 250, StaticResource: &StaticResource{ CreativeType: "application/x-shockwave-flash", - URI: URIString("http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf"), + URI: "http://demo.tremormedia.com/proddev/vast/300x250_companion_1.swf", }, - CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, }, { Width: 728, Height: 90, StaticResource: &StaticResource{ CreativeType: "image/jpeg", - URI: URIString("http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg"), + URI: "http://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg", }, TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/secondCompanion")}, + {Event: "creativeView", URI: "http://myTrackingURL/secondCompanion"}, }, - CompanionClickThrough: &CompanionClickThrough{URI: URIString("http://www.tremormedia.com")}, + CompanionClickThrough: &CompanionClickThrough{URI: "http://www.tremormedia.com"}, }, }, }, @@ -200,32 +200,32 @@ var _ = Describe("VAST", func() { ID: "602833", Wrapper: &Wrapper{ AdSystem: &AdSystem{Name: "Acudeo Compatible"}, - VASTAdTagURI: URIString("http://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml"), - Error: []Error{{URI: URIString("http://myErrorURL/wrapper/error")}}, - Impressions: []Impression{{URI: URIString("http://myTrackingURL/wrapper/impression")}}, + VASTAdTagURI: "http://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml", + Error: []Error{{URI: "http://myErrorURL/wrapper/error"}}, + Impressions: []Impression{{URI: "http://myTrackingURL/wrapper/impression"}}, Creatives: []CreativeWrapper{ { AdID: "602833", Linear: &LinearWrapper{ TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/creativeView")}, - {Event: "start", URI: URIString("http://myTrackingURL/wrapper/start")}, - {Event: "midpoint", URI: URIString("http://myTrackingURL/wrapper/midpoint")}, - {Event: "firstQuartile", URI: URIString("http://myTrackingURL/wrapper/firstQuartile")}, - {Event: "thirdQuartile", URI: URIString("http://myTrackingURL/wrapper/thirdQuartile")}, - {Event: "complete", URI: URIString("http://myTrackingURL/wrapper/complete")}, - {Event: "mute", URI: URIString("http://myTrackingURL/wrapper/mute")}, - {Event: "unmute", URI: URIString("http://myTrackingURL/wrapper/unmute")}, - {Event: "pause", URI: URIString("http://myTrackingURL/wrapper/pause")}, - {Event: "resume", URI: URIString("http://myTrackingURL/wrapper/resume")}, - {Event: "fullscreen", URI: URIString("http://myTrackingURL/wrapper/fullscreen")}, + {Event: "creativeView", URI: "http://myTrackingURL/wrapper/creativeView"}, + {Event: "start", URI: "http://myTrackingURL/wrapper/start"}, + {Event: "midpoint", URI: "http://myTrackingURL/wrapper/midpoint"}, + {Event: "firstQuartile", URI: "http://myTrackingURL/wrapper/firstQuartile"}, + {Event: "thirdQuartile", URI: "http://myTrackingURL/wrapper/thirdQuartile"}, + {Event: "complete", URI: "http://myTrackingURL/wrapper/complete"}, + {Event: "mute", URI: "http://myTrackingURL/wrapper/mute"}, + {Event: "unmute", URI: "http://myTrackingURL/wrapper/unmute"}, + {Event: "pause", URI: "http://myTrackingURL/wrapper/pause"}, + {Event: "resume", URI: "http://myTrackingURL/wrapper/resume"}, + {Event: "fullscreen", URI: "http://myTrackingURL/wrapper/fullscreen"}, }, }, }, { Linear: &LinearWrapper{ VideoClicks: &VideoClicks{ - ClickTrackings: []VideoClick{{URI: URIString("http://myTrackingURL/wrapper/click")}}, + ClickTrackings: []VideoClick{{URI: "http://myTrackingURL/wrapper/click"}}, }, }, }, @@ -233,7 +233,7 @@ var _ = Describe("VAST", func() { AdID: "602833-NonLinearTracking", NonLinearAds: &NonLinearAdsWrapper{ TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/creativeView")}, + {Event: "creativeView", URI: "http://myTrackingURL/wrapper/creativeView"}, }, }, }, @@ -250,9 +250,9 @@ var _ = Describe("VAST", func() { ID: "602867", Wrapper: &Wrapper{ AdSystem: &AdSystem{Name: "Acudeo Compatible"}, - VASTAdTagURI: URIString("http://demo.tremormedia.com/proddev/vast/vast_inline_nonlinear2.xml"), - Error: []Error{{URI: URIString("http://myErrorURL/wrapper/error")}}, - Impressions: []Impression{{URI: URIString("http://myTrackingURL/wrapper/impression")}}, + VASTAdTagURI: "http://demo.tremormedia.com/proddev/vast/vast_inline_nonlinear2.xml", + Error: []Error{{URI: "http://myErrorURL/wrapper/error"}}, + Impressions: []Impression{{URI: "http://myTrackingURL/wrapper/impression"}}, Creatives: []CreativeWrapper{ { AdID: "602867", @@ -262,11 +262,11 @@ var _ = Describe("VAST", func() { AdID: "602867-NonLinearTracking", NonLinearAds: &NonLinearAdsWrapper{ TrackingEvents: []Tracking{ - {Event: "creativeView", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/creativeView")}, - {Event: "expand", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/expand")}, - {Event: "collapse", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/collapse")}, - {Event: "acceptInvitation", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/acceptInvitation")}, - {Event: "close", URI: URIString("http://myTrackingURL/wrapper/nonlinear/creativeView/close")}, + {Event: "creativeView", URI: "http://myTrackingURL/wrapper/nonlinear/creativeView/creativeView"}, + {Event: "expand", URI: "http://myTrackingURL/wrapper/nonlinear/creativeView/expand"}, + {Event: "collapse", URI: "http://myTrackingURL/wrapper/nonlinear/creativeView/collapse"}, + {Event: "acceptInvitation", URI: "http://myTrackingURL/wrapper/nonlinear/creativeView/acceptInvitation"}, + {Event: "close", URI: "http://myTrackingURL/wrapper/nonlinear/creativeView/close"}, }, }, },