Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxNode committed Oct 30, 2024
1 parent 7ee6554 commit 0d01cd4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
63 changes: 44 additions & 19 deletions endpoints/info/bidders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ func TestPrepareBiddersResponseAll(t *testing.T) {
expected: `["a","z"]`,
},
{
name: "alias-one",
name: "alias-one-enabled",
givenBidders: config.BidderInfos{"a": enabledAlias},
expected: `["a"]`,
},
{
name: "alias-one-disabled",
givenBidders: config.BidderInfos{"a": disabledAlias},
expected: `["a"]`,
},
{
name: "alias-many-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": disabledAlias, "c": enabledCore, "d": enabledAlias},
expected: `["a","b","c","d"]`,
givenBidders: config.BidderInfos{"a": enabledAlias, "b": disabledAlias},
expected: `["a","b"]`,
},
{
name: "alias-many-sorted",
Expand Down Expand Up @@ -108,24 +113,29 @@ func TestPrepareBiddersResponseAllBaseOnly(t *testing.T) {
expected: `["a"]`,
},
{
name: "core-one-mixed",
name: "core-many-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": enabledCore},
expected: `["a","b"]`,
},
{
name: "core-one-mixed-sorted",
name: "core-many-sorted",
givenBidders: config.BidderInfos{"z": enabledCore, "a": enabledCore},
expected: `["a","z"]`,
},
{
name: "alias-one",
name: "alias-one-enabled",
givenBidders: config.BidderInfos{"a": enabledAlias},
expected: `[]`,
},
{
name: "alias-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": disabledAlias, "c": enabledCore, "d": enabledAlias},
expected: `["a","c"]`,
name: "alias-one-disabled",
givenBidders: config.BidderInfos{"a": disabledAlias},
expected: `[]`,
},
{
name: "alias-many",
givenBidders: config.BidderInfos{"a": enabledAlias, "b": enabledAlias},
expected: `[]`,
},
{
name: "mixed",
Expand Down Expand Up @@ -172,27 +182,32 @@ func TestPrepareBiddersResponseEnabledOnly(t *testing.T) {
expected: `[]`,
},
{
name: "core-one-mixed",
name: "core-many-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": enabledCore},
expected: `["b"]`,
},
{
name: "core-one-mixed-sorted",
name: "core-many-sorted",
givenBidders: config.BidderInfos{"z": enabledCore, "a": enabledCore},
expected: `["a","z"]`,
},
{
name: "alias-one",
name: "alias-one-enabled",
givenBidders: config.BidderInfos{"a": enabledAlias},
expected: `["a"]`,
},
{
name: "alias-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": disabledAlias, "c": enabledCore, "d": enabledAlias},
expected: `["c","d"]`,
name: "alias-one-disabled",
givenBidders: config.BidderInfos{"a": disabledAlias},
expected: `[]`,
},
{
name: "alias-mixed-sorted",
name: "alias-many-mixed",
givenBidders: config.BidderInfos{"a": enabledAlias, "b": disabledAlias},
expected: `["a"]`,
},
{
name: "alias-many-sorted",
givenBidders: config.BidderInfos{"z": enabledAlias, "a": enabledCore},
expected: `["a","z"]`,
},
Expand Down Expand Up @@ -241,17 +256,27 @@ func TestPrepareBiddersResponseEnabledOnlyBaseOnly(t *testing.T) {
expected: `[]`,
},
{
name: "core-one-mixed",
name: "core-many",
givenBidders: config.BidderInfos{"a": enabledCore, "b": enabledCore},
expected: `["a","b"]`,
},
{
name: "core-many-mixed",
givenBidders: config.BidderInfos{"a": disabledCore, "b": enabledCore},
expected: `["b"]`,
},
{
name: "core-one-mixed-sorted",
name: "core-many-sorted",
givenBidders: config.BidderInfos{"z": enabledCore, "a": enabledCore},
expected: `["a","z"]`,
},
{
name: "alias-one",
name: "alias-one-enabled",
givenBidders: config.BidderInfos{"a": enabledAlias},
expected: `[]`,
},
{
name: "alias-one-disabled",
givenBidders: config.BidderInfos{"a": enabledAlias},
expected: `[]`,
},
Expand Down
6 changes: 3 additions & 3 deletions endpoints/openrtb2/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1704,9 +1704,9 @@ func (deps *endpointDeps) processStoredRequests(requestJson []byte, impInfo []Im
}
}

// Apply default aliases, if they are provided
// apply default stored request
if deps.defaultRequest {
aliasedRequest, err := jsonpatch.MergePatch(deps.defReqJSON, resolvedRequest)
merged, err := jsonpatch.MergePatch(deps.defReqJSON, resolvedRequest)
if err != nil {
hasErr, Err := getJsonSyntaxError(resolvedRequest)
if hasErr {
Expand All @@ -1719,7 +1719,7 @@ func (deps *endpointDeps) processStoredRequests(requestJson []byte, impInfo []Im
}
return nil, nil, []error{err}
}
resolvedRequest = aliasedRequest
resolvedRequest = merged
}

// Apply any Stored Imps, if they exist. Since the JSON Merge Patch overrides arrays,
Expand Down
2 changes: 1 addition & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ func readDefaultRequestFromFile(defReqConfig config.DefReqConfig) []byte {
return []byte{}
}

// validate json is valid
if err := jsonutil.UnmarshalValid(defaultRequestJSON, &openrtb2model.BidRequest{}); err != nil {
// we might not have aliases defined, but will at least show that the JSON file is parsable.
glog.Fatalf("error parsing default request from file %s: %v", defReqConfig.FileSystem.FileName, err)
return []byte{}
}
Expand Down

0 comments on commit 0d01cd4

Please sign in to comment.