forked from bsm/openrtb
-
Notifications
You must be signed in to change notification settings - Fork 3
/
bid_test.go
74 lines (67 loc) · 2.03 KB
/
bid_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
72
73
74
package openrtb_test
import (
"errors"
"reflect"
"testing"
. "github.com/UnityTech/openrtb/v3"
)
func TestBid(t *testing.T) {
var subject *Bid
if err := fixture("bid", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}
exp := &Bid{
ID: "1",
ImpID: "1",
Price: 0.751371,
AdID: "52a5516d29e435137c6f6e74",
NURL: "http://ads.com/win/112770_1386565997?won=${AUCTION_PRICE}",
AdMarkup: "<html/>",
AdvDomain: []string{"ads.com"},
IURL: "http://ads.com/112770_1386565997.jpeg",
CampaignID: "52a5516d29e435137c6f6e74",
CreativeID: "52a5516d29e435137c6f6e74_1386565997",
DealID: "example_deal",
Attr: []int{},
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}
func TestBid_Validate(t *testing.T) {
subject := &Bid{}
if exp, got := ErrInvalidBidNoID, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
subject = &Bid{ID: "BIDID"}
if exp, got := ErrInvalidBidNoImpID, subject.Validate(); !errors.Is(exp, got) {
t.Fatalf("expected %v, got %v", exp, got)
}
}
func TestLoopmeARBid(t *testing.T) {
var subject *Bid
if err := fixture("bid.loopme.ar", &subject); err != nil {
t.Fatalf("expected no error, got %v", err)
}
exp := &Bid{
ID: "5d4b3b3be8250678c813f475",
ImpID: "1",
Price: 29.7,
AdID: "2056515",
NURL: "https://us.fake-url.com/tr?et=BID_WIN&a_ecp=29.7&a_price=${AUCTION_PRICE:BF}&name=imp_nurl",
AdMarkup: "<img>",
AdvDomain: []string{"unity.com"},
IURL: "https://fake-url.net/assets/2690-e3c0-aa99-9efd38cd1fa6.jpg",
CampaignID: "2001626",
CreativeID: "2056515",
Attr: []int{99},
Protocol: 2,
Cat: []string{"IAB19"},
LURL: "https://fake-url.com?et=BID_LOSS&meta=&a_id=${AUCTION_ID}&a_bid_id=${AUCTION_BID_ID}&a_loss_id=${AUCTION_LOSS}",
H: 320,
W: 480,
}
if got := subject; !reflect.DeepEqual(exp, got) {
t.Errorf("expected %+v, got %+v", exp, got)
}
}