github.com/prebid/prebid-server/v2@v2.18.0/adapters/vrtcal/params_test.go (about) 1 package vrtcal 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/prebid/prebid-server/v2/openrtb_ext" 8 ) 9 10 //Vrtcal doesn't currently require any custom fields. This file is included for conformity only 11 //We do include an unused, non-required custom param in static/bidder-params/vrtcal.json, but only to hinder the prebid server from crashing by looking for at least 1 custom param 12 13 // This file actually intends to test static/bidder-params/vrtcal.json 14 // 15 // These also validate the format of the external API: request.imp[i].ext.prebid.bidder.vrtcal 16 // TestValidParams makes sure that the Vrtcal schema accepts all imp.ext fields which we intend to support. 17 func TestValidParams(t *testing.T) { 18 validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") 19 if err != nil { 20 t.Fatalf("Failed to fetch the json-schemas. %v", err) 21 } 22 23 for _, validParam := range validParams { 24 if err := validator.Validate(openrtb_ext.BidderVrtcal, json.RawMessage(validParam)); err != nil { 25 t.Errorf("Schema rejected Vrtcal params: %s", validParam) 26 } 27 } 28 } 29 30 // TestInvalidParams makes sure that the Vrtcal schema rejects all the imp.ext fields we don't support. 31 func TestInvalidParams(t *testing.T) { 32 validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") 33 if err != nil { 34 t.Fatalf("Failed to fetch the json-schemas. %v", err) 35 } 36 37 for _, invalidParam := range invalidParams { 38 if err := validator.Validate(openrtb_ext.BidderVrtcal, json.RawMessage(invalidParam)); err == nil { 39 t.Errorf("Schema allowed unexpected params: %s", invalidParam) 40 } 41 } 42 } 43 44 var validParams = []string{} 45 46 var invalidParams = []string{}