forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparam_test.go
46 lines (38 loc) · 1017 Bytes
/
param_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package bigoad
import (
"encoding/json"
"testing"
"github.com/prebid/prebid-server/v3/openrtb_ext"
)
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json schema. %v", err)
}
for _, p := range validParams {
if err := validator.Validate(openrtb_ext.BidderBigoAd, json.RawMessage(p)); err != nil {
t.Errorf("Schema rejected valid params: %s", p)
}
}
}
func TestInvalidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json schema. %v", err)
}
for _, p := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderBigoAd, json.RawMessage(p)); err == nil {
t.Errorf("Schema allowed invalid params: %s", p)
}
}
}
var validParams = []string{
`{"sspid": "123"}`,
}
var invalidParams = []string{
``,
`null`,
`[]`,
`{}`,
`{"xxx": "baidu.com"}`,
}