Skip to content

Commit ad2f6c0

Browse files
committed
Added regression test
1 parent c8f5bcc commit ad2f6c0

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

fixtures_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ var testFixtures = struct {
6565
"banner":{
6666
"w":300,
6767
"h":250,
68+
"wmin":300,
69+
"hmin":250,
6870
"pos":1,
6971
"battr":[
7072
13

request_test.go

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99

1010
var _ = Describe("Request", func() {
1111
var subject *Request
12+
var sptr = func(s string) *string { return &s }
13+
var iptr = func(n int) *int { return &n }
14+
var fptr = func(f float32) *float32 { return &f }
1215

1316
BeforeEach(func() {
1417
subject = new(Request)
@@ -17,7 +20,64 @@ var _ = Describe("Request", func() {
1720
It("should should parse requests", func() {
1821
req, err := ParseRequest(bytes.NewBuffer(testFixtures.expandableCreative))
1922
Expect(err).NotTo(HaveOccurred())
20-
Expect(req).To(BeAssignableToTypeOf(&Request{}))
23+
24+
Expect(req.Imp).To(Equal([]Impression{
25+
{
26+
Id: sptr("1"),
27+
Banner: &Banner{
28+
W: iptr(300),
29+
H: iptr(250),
30+
Wmin: iptr(300),
31+
Hmin: iptr(250),
32+
Pos: iptr(1),
33+
Topframe: iptr(0),
34+
Battr: []int{13},
35+
Expdir: []int{2, 4},
36+
},
37+
Instl: iptr(0),
38+
Bidfloor: fptr(0),
39+
Bidfloorcur: sptr("USD"),
40+
Secure: iptr(0),
41+
Iframebuster: []string{"vendor1.com", "vendor2.com"},
42+
},
43+
}))
44+
45+
Expect(req.Site).To(Equal(&Site{
46+
Id: sptr("1345135123"),
47+
Name: sptr("Site ABCD"),
48+
Domain: sptr("siteabcd.com"),
49+
Page: sptr("http://siteabcd.com/page.htm"),
50+
Privacypolicy: iptr(1),
51+
Ref: sptr("http://referringsite.com/referringpage.htm"),
52+
Publisher: &Publisher{Id: sptr("pub12345"), Name: sptr("Publisher A")},
53+
}))
54+
55+
Expect(req.Device).To(Equal(&Device{
56+
Dnt: iptr(0),
57+
Ua: sptr("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"),
58+
Ip: sptr("64.124.253.1"),
59+
Os: sptr("OS X"),
60+
Js: iptr(1),
61+
Connectiontype: iptr(0),
62+
Devicetype: iptr(0),
63+
Flashver: sptr("10.1"),
64+
}))
65+
66+
Expect(req.User).To(Equal(&User{
67+
Id: sptr("456789876567897654678987656789"),
68+
Buyeruid: sptr("545678765467876567898765678987654"),
69+
Data: []Data{
70+
{
71+
Id: sptr("6"),
72+
Name: sptr("Data Provider 1"),
73+
Segment: []Segment{
74+
{Id: sptr("12341318394918"), Name: sptr("auto intenders")},
75+
{Id: sptr("1234131839491234"), Name: sptr("auto enthusiasts")},
76+
{Id: sptr("23423424"), Name: sptr("data-provider1-age"), Value: sptr("30-40")},
77+
},
78+
},
79+
},
80+
}))
2181
})
2282

2383
Describe("ParseRequestBytes()", func() {

0 commit comments

Comments
 (0)