本文整理匯總了Golang中github.com/evandigby/rtb.BidRequest類的典型用法代碼示例。如果您正苦於以下問題:Golang BidRequest類的具體用法?Golang BidRequest怎麽用?Golang BidRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BidRequest類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestBiddingPacerFalse
// TestBiddingPacerFalse tests that the bidder will not bid when the pacer replys false to CanBid
// Expected result is nil
func TestBiddingPacerFalse(t *testing.T) {
r := new(rtb.BidRequest)
r.Imp = make([]rtb.Imp, 1)
r.Imp[0] = rtb.Imp{}
pacer := mocks.NewMockPacer(map[int64]bool{100: false})
campaign := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)
campaignsReturnedByTargeting := []rtb.Campaign{campaign}
cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1)}, map[int64]error{100: nil}, nil)
b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())
response, _, err := b.Bid()
if err != nil {
t.Fail()
}
if response != nil {
t.FailNow()
}
}
示例2: TestBiddingMatchedTargetCorrectAmount
// TestBiddingMatchedTargetCorrectAmount tests that the bidder bids the correct amount
// Expected result is a bid response that is populated by a single bid with the correct bid amount
func TestBiddingMatchedTargetCorrectAmount(t *testing.T) {
r := new(rtb.BidRequest)
r.Imp = make([]rtb.Imp, 1)
r.Imp[0] = rtb.Imp{}
pacer := mocks.NewMockPacer(map[int64]bool{100: true})
campaign := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.32), rtb.DollarsToMicroCents(1), nil)
campaignsReturnedByTargeting := []rtb.Campaign{campaign}
cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1)}, map[int64]error{100: nil}, nil)
b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())
expectedBidAmount := float64(0.32)
response, _, err := b.Bid()
if err != nil {
t.Fail()
}
if response == nil {
t.FailNow()
}
if response.Seatbid == nil {
t.FailNow()
}
if len(response.Seatbid) != 1 {
t.Fail()
}
if response.Seatbid[0].Bid == nil {
t.FailNow()
}
if len(response.Seatbid[0].Bid) != 1 {
t.FailNow()
}
if response.Seatbid[0].Bid[0].Cid != strconv.FormatInt(campaignsReturnedByTargeting[0].Id(), 10) {
t.Fail()
}
if response.Seatbid[0].Bid[0].Price != expectedBidAmount {
t.Fail()
}
}
示例3: TestBiddingFirstCampaignOutOfFunds
// TestBiddingMatchedTarget tests that the bidder will bid on the first campaign returned by the bidder that has a remaining daily budget
// Expected result is a bid response that is populated by a single bid with a campaign ID matching the first campaigned returned by the provider
func TestBiddingFirstCampaignOutOfFunds(t *testing.T) {
r := new(rtb.BidRequest)
r.Imp = make([]rtb.Imp, 1)
r.Imp[0] = rtb.Imp{}
pacer := mocks.NewMockPacer(map[int64]bool{100: true, 101: true})
campaign1 := mocks.NewMockCampaign(100, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)
campaign2 := mocks.NewMockCampaign(101, rtb.CpmToMicroCents(0.25), rtb.DollarsToMicroCents(1), nil)
campaignsReturnedByTargeting := []rtb.Campaign{campaign1, campaign2}
cp := mocks.NewMockCampaignProvider(campaignsReturnedByTargeting, map[int64]int64{100: rtb.DollarsToMicroCents(1), 101: rtb.DollarsToMicroCents(1)}, map[int64]error{100: rtb.NewTransactionError("test", true), 101: nil}, nil)
b := NewBidRequestBidder(r, cp, pacer, time.Now().UTC())
response, _, err := b.Bid()
if err != nil {
t.Fail()
}
if response == nil {
t.FailNow()
}
if response.Seatbid == nil {
t.FailNow()
}
if len(response.Seatbid) != 1 {
t.Fail()
}
if response.Seatbid[0].Bid == nil {
t.FailNow()
}
if len(response.Seatbid[0].Bid) != 1 {
t.FailNow()
}
if response.Seatbid[0].Bid[0].Cid != strconv.FormatInt(campaignsReturnedByTargeting[1].Id(), 10) {
t.Fail()
}
}