Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avolokha committed Jul 26, 2021
1 parent 5562e16 commit 1b088c0
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adapters/admixer/admixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func preprocess(imp *openrtb2.Imp) error {
}

//don't use regexp due to possible performance reduce
if len(admixerExt.ZoneId) != 36 {
if len(admixerExt.ZoneId) < 32 || len(admixerExt.ZoneId) > 36 {
return &errortypes.BadInput{
Message: "ZoneId must be UUID/GUID",
}
Expand Down
89 changes: 89 additions & 0 deletions adapters/admixer/admixertest/exemplary/optional-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,53 @@
}
}
}
},
{
"id": "test-imp-id",
"bidfloor": 0.5,
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"bidder": {
"zone": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"customParams": {
"foo": [
"bar",
"baz"
]
}
},
"customFloor": 0.9
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"ext": {
"bidder": {
"customFloor": 0.9,
"zone": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
}
}
]
},
Expand Down Expand Up @@ -136,6 +183,48 @@
]
}
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"tagid": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"bidfloor": 0.5,
"ext": {
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
},
{
"id": "test-imp-id",
"banner": {
"format": [
{
"w": 728,
"h": 90
}
]
},
"tagid": "2eb6bd58-865c-47ce-af7f-a918108c3fd2",
"bidfloor": 0.9,
"ext": {
"customParams": {
"foo": [
"bar",
"baz"
]
}
}
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions adapters/admixer/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var validParams = []string{
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customFloor": 0.1}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customParams": {"foo": "bar"}}`,
`{"zone": "9ff668a2-4122-462e-aaf8-36ea3a54ba21", "customFloor": 0.1, "customParams": {"foo": ["bar", "baz"]}}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA21"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA212"}`,
}

var invalidParams = []string{
Expand All @@ -54,4 +56,6 @@ var invalidParams = []string{
`{"zone": "123", "customFloor": "0.1"}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customFloor": -0.1}`,
`{"zone": "9FF668A2-4122-462E-AAF8-36EA3A54BA21", "customParams": "foo: bar"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA2"}`,
`{"zone": "9FF668A24122462EAAF836EA3A54BA2112336"}`,
}

0 comments on commit 1b088c0

Please sign in to comment.