Skip to content

Commit

Permalink
Inclusão de teste de parametro
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelfabelopencircle committed Nov 23, 2024
1 parent 886bf03 commit 0d9fd7f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions adapters/blue/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package blue

import (
"encoding/json"
"testing"

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

// This file actually intends to test static/bidder-params/blue.json TODO: MUST BE CREATED
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.BidderBlue, json.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected blue params: %s", validParam)
}
}
}

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.BidderBlue, json.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
}
}
}

var validParams = []string{
`{"publisherId":"1234"}`,
`{"publisherId":"1234", "placementId":"12345"}`,
}

var invalidParams = []string{
``,
`null`,
`true`,
`5`,
`4.2`,
`[]`,
`{}`,
}

0 comments on commit 0d9fd7f

Please sign in to comment.