-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapter Name Case Insensitive: ext.prebid.multibid #3217
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just left comments regarding tests
desc: "Lowercase prebid.MultiBid.Bidder is found in the BidderName list, entry is mapped", | ||
inPrebid: &openrtb_ext.ExtRequestPrebid{ | ||
MultiBid: []*openrtb_ext.ExtMultiBid{ | ||
{Bidder: "appnexus"}, | ||
}, | ||
}, | ||
expected: map[string]openrtb_ext.ExtMultiBid{ | ||
"appnexus": {Bidder: "appnexus"}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add another test case just like this, except the Bidder is capitalized: (i.e APPNEXUS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -5750,3 +5750,182 @@ func TestSetSeatNonBid(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestBuildMultiBidMap(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also a JSON test in /exchangetest
similar to multi-bids.json
, where we can test the case insensitivity there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! That extra test revealed another spot where case insensitivity was needed inside function buildRequestExtMultiBid()
. Added exchange/exchangetest/multi-bids-mixed-case.json
.
exchange/exchange_test.go
Outdated
multiBidMap := buildMultiBidMap(tc.inPrebid) | ||
assert.Equal(t, tc.expected, multiBidMap, tc.desc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add t.Run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -2259,8 +2259,13 @@ func TestTimeoutComputation(t *testing.T) { | |||
func TestExchangeJSON(t *testing.T) { | |||
if specFiles, err := os.ReadDir("./exchangetest"); err == nil { | |||
for _, specFile := range specFiles { | |||
if !strings.HasSuffix(specFile.Name(), ".json") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added so vim's .swp
files wouldn't error. Can remove if you want
@@ -467,12 +467,12 @@ func buildRequestExtMultiBid(adapter string, reqMultiBid []*openrtb_ext.ExtMulti | |||
adapterMultiBid := make([]*openrtb_ext.ExtMultiBid, 0) | |||
for _, multiBid := range reqMultiBid { | |||
if multiBid.Bidder != "" { | |||
if multiBid.Bidder == adapter || isBidderInExtAlternateBidderCodes(adapter, multiBid.Bidder, adapterABC) { | |||
if strings.ToLower(multiBid.Bidder) == adapter || isBidderInExtAlternateBidderCodes(adapter, strings.ToLower(multiBid.Bidder), adapterABC) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use openrtb_ext.NormalizeBidderName()
here, exchange/exchangetest/multi-bids-with-extra-bids.json
fails. Whether or not the expectations in said test are correct we can leave for a future discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Normalization was done in
buildMultiBidMap(prebid *openrtb_ext.ExtRequestPrebid)
inside fileexchange/exchange.go
. Let me know your thoughts.