From 0d9fd7f24a0e1e8d260b376680042fd569b5860d Mon Sep 17 00:00:00 2001 From: Samuel Fabel Date: Sat, 23 Nov 2024 12:33:36 -0300 Subject: [PATCH] =?UTF-8?q?Inclus=C3=A3o=20de=20teste=20de=20parametro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapters/blue/params_test.go | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 adapters/blue/params_test.go diff --git a/adapters/blue/params_test.go b/adapters/blue/params_test.go new file mode 100644 index 0000000000..3d53cdf72e --- /dev/null +++ b/adapters/blue/params_test.go @@ -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`, + `[]`, + `{}`, +}