|
1 | | -package openrtb |
| 1 | +package openrtb_test |
2 | 2 |
|
3 | 3 | import ( |
4 | | - . "github.com/onsi/ginkgo" |
5 | | - . "github.com/onsi/gomega" |
| 4 | + "errors" |
| 5 | + "reflect" |
| 6 | + "testing" |
| 7 | + |
| 8 | + . "github.com/UnityTech/openrtb" |
6 | 9 | ) |
7 | 10 |
|
8 | | -var _ = Describe("Audio", func() { |
| 11 | +func TestAudio(t *testing.T) { |
9 | 12 | var subject *Audio |
| 13 | + if err := fixture("audio", &subject); err != nil { |
| 14 | + t.Fatalf("expected no error, got %v", err) |
| 15 | + } |
10 | 16 |
|
11 | | - BeforeEach(func() { |
12 | | - err := fixture("audio", &subject) |
13 | | - Expect(err).NotTo(HaveOccurred()) |
14 | | - }) |
15 | | - |
16 | | - It("should parse correctly", func() { |
17 | | - Expect(subject).To(Equal(&Audio{ |
18 | | - Mimes: []string{ |
19 | | - "audio/mp4", |
20 | | - }, |
21 | | - MinDuration: 5, |
22 | | - MaxDuration: 30, |
23 | | - Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, |
24 | | - Sequence: 1, |
25 | | - BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, |
26 | | - MaxExtended: 30, |
27 | | - MinBitrate: 300, |
28 | | - MaxBitrate: 1500, |
29 | | - Delivery: []int{ContentDeliveryProgressive}, |
30 | | - CompanionAd: []Banner{ |
31 | | - {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, |
32 | | - {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, |
33 | | - }, |
34 | | - API: []int{APIFrameworkVPAID1, APIFrameworkVPAID2}, |
35 | | - CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, |
36 | | - })) |
37 | | - }) |
38 | | - |
39 | | - It("should validate", func() { |
40 | | - Expect((&Audio{ |
41 | | - MinDuration: 5, |
42 | | - MaxDuration: 30, |
43 | | - Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, |
44 | | - Sequence: 1, |
45 | | - BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, |
46 | | - MaxExtended: 30, |
47 | | - MinBitrate: 300, |
48 | | - MaxBitrate: 1500, |
49 | | - Delivery: []int{ContentDeliveryProgressive}, |
50 | | - CompanionAd: []Banner{ |
51 | | - {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, |
52 | | - {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, |
53 | | - }, |
54 | | - CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, |
55 | | - }).Validate()).To(Equal(ErrInvalidAudioNoMimes)) |
56 | | - }) |
| 17 | + exp := &Audio{ |
| 18 | + Mimes: []string{ |
| 19 | + "audio/mp4", |
| 20 | + }, |
| 21 | + MinDuration: 5, |
| 22 | + MaxDuration: 30, |
| 23 | + Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, |
| 24 | + Sequence: 1, |
| 25 | + BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, |
| 26 | + MaxExtended: 30, |
| 27 | + MinBitrate: 300, |
| 28 | + MaxBitrate: 1500, |
| 29 | + Delivery: []int{ContentDeliveryProgressive}, |
| 30 | + CompanionAd: []Banner{ |
| 31 | + {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, |
| 32 | + {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, |
| 33 | + }, |
| 34 | + API: []int{APIFrameworkVPAID1, APIFrameworkVPAID2}, |
| 35 | + CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, |
| 36 | + } |
| 37 | + if got := subject; !reflect.DeepEqual(exp, got) { |
| 38 | + t.Errorf("expected %+v, got %+v", exp, got) |
| 39 | + } |
| 40 | +} |
57 | 41 |
|
58 | | -}) |
| 42 | +func TestAudio_Validate(t *testing.T) { |
| 43 | + subject := &Audio{ |
| 44 | + MinDuration: 5, |
| 45 | + MaxDuration: 30, |
| 46 | + Protocols: []int{AudioProtocolDAAST1, AudioProtocolDAAST1Wrapper}, |
| 47 | + Sequence: 1, |
| 48 | + BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, |
| 49 | + MaxExtended: 30, |
| 50 | + MinBitrate: 300, |
| 51 | + MaxBitrate: 1500, |
| 52 | + Delivery: []int{ContentDeliveryProgressive}, |
| 53 | + CompanionAd: []Banner{ |
| 54 | + {W: 300, H: 250, ID: "1234567893-1", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}, ExpDir: []int{ExpDirRight, ExpDirDown}}, |
| 55 | + {W: 728, H: 90, ID: "1234567893-2", Pos: AdPosAboveFold, BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert}}, |
| 56 | + }, |
| 57 | + CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML}, |
| 58 | + } |
| 59 | + if exp, got := ErrInvalidAudioNoMimes, subject.Validate(); !errors.Is(exp, got) { |
| 60 | + t.Fatalf("expected %v, got %v", exp, got) |
| 61 | + } |
| 62 | +} |
0 commit comments