-
Notifications
You must be signed in to change notification settings - Fork 750
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
Bug: Assert BidderResponses array in adapter JSON tests #2804
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VeronikaSolovei9
previously approved these changes
Jun 13, 2023
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!
IX changes LGTM |
Sharethrough changes LGTM |
VRTCAL changes LGTM |
AlexBVolcy
previously approved these changes
Jun 13, 2023
SSPBC changes LGTM |
ADF changes LGTM. |
braizhas
approved these changes
Jun 15, 2023
Smaato changes LGTM |
guscarreon
dismissed stale reviews from AlexBVolcy and VeronikaSolovei9
via
June 26, 2023 06:04
5427894
AlexBVolcy
approved these changes
Jun 26, 2023
VeronikaSolovei9
approved these changes
Jun 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request corrects a bug in the adapter JSON test framework. Current version of
testMakeBidsImpl
compares the expected bid responses with the returned bid responses in thefor
loop in line 460 shown below:Under the current logic, if a JSON test file comes with an empty
"expectedBidResponses"
field, no assertions are made even if thebidResponses
array was populated with elements. This makes the test framework unable to identify if a given test returns a valid*adapters.BidderResponse
when it was not supposed to. To correct this issue, this PR adds the following:But a complementary change is needed if we add this check: consider the
MakeBids
implementation shown below. If a test case exits in line 200,nil
values for*adapters.BidderResponse
and[]error
are returned.Consequently, the
append()
calls in lines 452 and 453 ofadapters/adapterstest/test_json.go
will add thenil
references to thebidResponses
andbidsErrs
arrays which complicates the proposedassert.Len(t, bidResponses, len(spec.BidResponses)..
assertion. Therefore, we should preventnil
elements from being added:With the proposed changes, many JSON test files needed modification. One that is particularly common, is to substitute an empty
"expectedBidResponses": []
with"expectedBidResponses": [{"currency":"USD","bids":[]}]
like in theadapters/zeta_global_ssp/zeta_global_ssp-test/supplemental/invalid-bid-type.json
file below:The reason behind this change is that function
NewBidderResponseWithBidsCapacity
, that gets called insideMakeBids(...)
by every adapter, returns aBidderResponse
with an empty, non-nilBids
array and theCurrency
set to US dollars:Please let me know your thoughts.