Skip to content

Commit

Permalink
Merge pull request #4 from bruno-siira/pr-review-comments-12-16-24
Browse files Browse the repository at this point in the history
PR Review Comments 12-16-24
  • Loading branch information
dirk-rd authored Dec 22, 2024
2 parents 6bac6cd + 905485d commit 0623316
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 12 deletions.
2 changes: 0 additions & 2 deletions adapters/resetdigital/.gitignore

This file was deleted.

58 changes: 58 additions & 0 deletions adapters/resetdigital/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package resetdigital

import (
"encoding/json"
"testing"

"github.com/prebid/prebid-server/v3/openrtb_ext"
)

// TestValidParams tests valid parameter(s) declared in openrtb_ext/imp_resetdigital.go
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}

for _, validParam := range validParams {
if err := validator.Validate(openrtb_ext.BidderResetDigital, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected ResetDigital params: %s \n Error: %s", validParam, err)
}
}
}

// TestValidParams tests invalid parameter(s) declared in openrtb_ext/imp_resetdigital.go
func TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}

for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderResetDigital, json.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected ResetDigital params: %s", invalidParam)
}
}
}

// list of valid parameter(s) test cases
var validParams = []string{
`{"placement_id":"1000"}`,
`{"placement_id":"0"}`,
`{"placement_id":"abc"}`,
`{"placement_id":"123abc"}`,
`{}`,
`{"cp":"1000"}`,
}

// list of invalid parameter(s) test cases
var invalidParams = []string{
``,
`null`,
`true`,
`5`,
`4.2`,
`[]`,
`{"placement_id":}`,
`{"placement_id":""}`,
}
14 changes: 5 additions & 9 deletions adapters/resetdigital/resetdigital.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R
continue
}

bidType, err := GetMediaTypeForImp(requestImps[bid.ImpID])
if err != nil {
errs = append(errs, err)
continue
}
bidType := GetMediaTypeForImp(requestImps[bid.ImpID])

b := &adapters.TypedBid{
Bid: bid,
Expand Down Expand Up @@ -295,13 +291,13 @@ func getBidType(imp openrtb2.Imp) (openrtb_ext.BidType, error) {
return "", fmt.Errorf("failed to find matching imp for bid %s", imp.ID)
}

func GetMediaTypeForImp(reqImp openrtb2.Imp) (openrtb_ext.BidType, error) {
func GetMediaTypeForImp(reqImp openrtb2.Imp) openrtb_ext.BidType {

if reqImp.Video != nil {
return openrtb_ext.BidTypeVideo, nil
return openrtb_ext.BidTypeVideo
}
if reqImp.Audio != nil {
return openrtb_ext.BidTypeAudio, nil
return openrtb_ext.BidTypeAudio
}
return openrtb_ext.BidTypeBanner, nil
return openrtb_ext.BidTypeBanner
}
2 changes: 1 addition & 1 deletion exchange/adapter_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder {
openrtb_ext.BidderQT: qt.Builder,
openrtb_ext.BidderReadpeak: readpeak.Builder,
openrtb_ext.BidderRelevantDigital: relevantdigital.Builder,
openrtb_ext.BidderRevcontent: revcontent.Builder,
openrtb_ext.BidderResetDigital: resetdigital.Builder,
openrtb_ext.BidderRevcontent: revcontent.Builder,
openrtb_ext.BidderRichaudience: richaudience.Builder,
openrtb_ext.BidderRise: rise.Builder,
openrtb_ext.BidderRoulax: roulax.Builder,
Expand Down

0 comments on commit 0623316

Please sign in to comment.