From e3aac21c17f0b1e72960eb4a7f947a30c84079d5 Mon Sep 17 00:00:00 2001 From: Ezequiel Maraschio Date: Fri, 3 Mar 2017 14:34:04 -0300 Subject: [PATCH 1/2] Use constants and remove magic numbers on tests --- audio_test.go | 22 +++++++++++----------- bidrequest_test.go | 2 +- device_test.go | 4 ++-- native/request/request_test.go | 2 +- video_test.go | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/audio_test.go b/audio_test.go index fe09cea..4a4937e 100644 --- a/audio_test.go +++ b/audio_test.go @@ -22,17 +22,17 @@ var _ = Describe("Audio", func() { MaxDuration: 30, Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, Sequence: 1, - BAttr: []int{13, 14}, + BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, MaxExtended: 30, MinBitrate: 300, MaxBitrate: 1500, - Delivery: []int{2}, + Delivery: []int{ContentDeliveryProgressive}, CompanionAd: []Banner{ - {W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}}, - {W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}}, + {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, + {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, }, - API: []int{1, 2}, - CompanionType: []int{1, 2}, + API: []int{APIFrameworkVPAID1, APIFrameworkVPAID2}, + CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, })) }) @@ -42,16 +42,16 @@ var _ = Describe("Audio", func() { MaxDuration: 30, Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, Sequence: 1, - BAttr: []int{13, 14}, + BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, MaxExtended: 30, MinBitrate: 300, MaxBitrate: 1500, - Delivery: []int{2}, + Delivery: []int{ContentDeliveryProgressive}, CompanionAd: []Banner{ - {W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}}, - {W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}}, + {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, + {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, }, - CompanionType: []int{1, 2}, + CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, }).Validate()).To(Equal(ErrInvalidAudioNoMimes)) }) diff --git a/bidrequest_test.go b/bidrequest_test.go index fae9988..9a491cc 100644 --- a/bidrequest_test.go +++ b/bidrequest_test.go @@ -30,7 +30,7 @@ var _ = Describe("BidRequest", func() { { ID: "1", Secure: json.Number("1"), - Banner: &Banner{W: 300, H: 250, Pos: AdPosAboveFold, BAttr: []int{13}}, + Banner: &Banner{W: 300, H: 250, Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated}}, }, }, Site: &Site{ diff --git a/device_test.go b/device_test.go index 9cf52b5..3649fb8 100644 --- a/device_test.go +++ b/device_test.go @@ -36,8 +36,8 @@ var _ = Describe("Device", func() { OS: "iOS", OSVer: "6.1", JS: 1, - ConnType: 3, - DeviceType: 1, + ConnType: ConnTypeCell, + DeviceType: DeviceTypeMobile, })) }) }) diff --git a/native/request/request_test.go b/native/request/request_test.go index 8de9e5c..2d4eb99 100644 --- a/native/request/request_test.go +++ b/native/request/request_test.go @@ -24,7 +24,7 @@ var _ = Describe("Request", func() { {ID: 128, Image: &Image{TypeID: ImageTypeMain, WidthMin: 836, HeightMin: 627, Width: 1000, Height: 800, Mimes: []string{"image/jpg"}}}, {ID: 126, Required: 1, Data: &Data{TypeID: DataTypeSponsored, Length: 25}}, {ID: 127, Required: 1, Data: &Data{TypeID: DataTypeDesc, Length: 140}}, - {ID: 4, Video: &Video{MinDuration: 15, MaxDuration: 30, Protocols: []int{2, 3}, Mimes: []string{"video/mp4"}}}, + {ID: 4, Video: &Video{MinDuration: 15, MaxDuration: 30, Protocols: []int{VideoProtoVAST2, VideoProtoVAST3}, Mimes: []string{"video/mp4"}}}, }, })) }) diff --git a/video_test.go b/video_test.go index 124aa71..eee9269 100644 --- a/video_test.go +++ b/video_test.go @@ -28,20 +28,20 @@ var _ = Describe("Video", func() { H: 480, Linearity: VideoLinearityLinear, Sequence: 1, - BAttr: []int{13, 14}, + BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, MaxExtended: 30, MinBitrate: 300, MaxBitrate: 1500, BoxingAllowed: iptr(1), PlaybackMethod: []int{VideoPlaybackAutoSoundOn, VideoPlaybackClickToPlay}, - Delivery: []int{2}, + Delivery: []int{ContentDeliveryProgressive}, Pos: AdPosAboveFold, CompanionAd: []Banner{ - {W: 300, H: 250, ID: "1234567893-1", Pos: 1, BAttr: []int{13, 14}, ExpDir: []int{ExpDirRight, ExpDirDown}}, - {W: 728, H: 90, ID: "1234567893-2", Pos: 1, BAttr: []int{13, 14}}, + {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, + {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, }, - Api: []int{1, 2}, - CompanionType: []int{1, 2}, + Api: []int{APIFrameworkVPAID1, APIFrameworkVPAID2}, + CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, })) }) From 48a0445251b80ef9e76d96fce8f3285cfbbafe90 Mon Sep 17 00:00:00 2001 From: Ezequiel Maraschio Date: Fri, 3 Mar 2017 15:02:45 -0300 Subject: [PATCH 2/2] Add bsm/openrtb package on request test --- native/request/request_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/native/request/request_test.go b/native/request/request_test.go index 2d4eb99..0f84260 100644 --- a/native/request/request_test.go +++ b/native/request/request_test.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "testing" + "github.com/bsm/openrtb" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) @@ -24,7 +25,7 @@ var _ = Describe("Request", func() { {ID: 128, Image: &Image{TypeID: ImageTypeMain, WidthMin: 836, HeightMin: 627, Width: 1000, Height: 800, Mimes: []string{"image/jpg"}}}, {ID: 126, Required: 1, Data: &Data{TypeID: DataTypeSponsored, Length: 25}}, {ID: 127, Required: 1, Data: &Data{TypeID: DataTypeDesc, Length: 140}}, - {ID: 4, Video: &Video{MinDuration: 15, MaxDuration: 30, Protocols: []int{VideoProtoVAST2, VideoProtoVAST3}, Mimes: []string{"video/mp4"}}}, + {ID: 4, Video: &Video{MinDuration: 15, MaxDuration: 30, Protocols: []int{openrtb.VideoProtoVAST2, openrtb.VideoProtoVAST3}, Mimes: []string{"video/mp4"}}}, }, })) })