forked from bsm/openrtb
-
Notifications
You must be signed in to change notification settings - Fork 3
/
video_test.go
71 lines (66 loc) · 2.22 KB
/
video_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package openrtb_test
import (
"errors"
"reflect"
"testing"
. "github.com/UnityTech/openrtb/v3"
)
func TestVideo(t *testing.T) {
var subject *Video
if err := fixture("video", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}
boxingAllowed := 1
exp := &Video{
Mimes: []string{
"video/x-flv",
"video/mp4",
"application/x-shockwave-flash",
"application/javascript",
},
MinDuration: 5,
MaxDuration: 30,
Protocols: []int{VideoProtoVAST2, VideoProtoVAST3},
W: 640,
H: 480,
Linearity: VideoLinearityLinear,
Sequence: 1,
BAttr: []int{CreativeAttributeUserInitiated, CreativeAttributeWindowsDialogOrAlert},
MaxExtended: 30,
MinBitrate: 300,
MaxBitrate: 1500,
BoxingAllowed: &boxingAllowed,
PlaybackMethod: []int{VideoPlaybackAutoSoundOn, VideoPlaybackClickToPlay},
Delivery: []int{ContentDeliveryProgressive},
Pos: AdPosAboveFold,
CompanionAd: []Banner{
{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}},
},
Placement: VideoPlacementInStream,
Api: []int{APIFrameworkVPAID1, APIFrameworkVPAID2},
CompanionType: []int{VASTCompanionStatic, VASTCompanionHTML},
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}
func TestVideo_Validate(t *testing.T) {
subject := &Video{}
if exp, got := ErrInvalidVideoNoMimes, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
subject = &Video{Mimes: []string{"video/mp4"}}
if exp, got := ErrInvalidVideoNoLinearity, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
subject = &Video{
MinDuration: 1,
MaxDuration: 1,
Linearity: VideoLinearityNonLinear,
Mimes: []string{"video/mp4"},
}
if exp, got := ErrInvalidVideoNoProtocols, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
}