Added support for arbitrary_key (#910)
This commit is contained in:
committed by
delvedor
parent
cefd4240a2
commit
0cd9f024c9
@ -36,7 +36,8 @@ const supportedFeatures = [
|
|||||||
'groovy_scripting',
|
'groovy_scripting',
|
||||||
'headers',
|
'headers',
|
||||||
'transform_and_set',
|
'transform_and_set',
|
||||||
'catch_unauthorized'
|
'catch_unauthorized',
|
||||||
|
'arbitrary_key'
|
||||||
]
|
]
|
||||||
|
|
||||||
class TestRunner {
|
class TestRunner {
|
||||||
@ -312,7 +313,20 @@ class TestRunner {
|
|||||||
* @returns {TestRunner}
|
* @returns {TestRunner}
|
||||||
*/
|
*/
|
||||||
set (key, name) {
|
set (key, name) {
|
||||||
|
if (key.includes('_arbitrary_key_')) {
|
||||||
|
var currentVisit = null
|
||||||
|
for (const path of key.split('.')) {
|
||||||
|
if (path === '_arbitrary_key_') {
|
||||||
|
const keys = Object.keys(currentVisit)
|
||||||
|
const arbitraryKey = keys[getRandomInt(0, keys.length)]
|
||||||
|
this.stash.set(name, arbitraryKey)
|
||||||
|
} else {
|
||||||
|
currentVisit = delve(this.response, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.stash.set(name, delve(this.response, key))
|
this.stash.set(name, delve(this.response, key))
|
||||||
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,4 +780,8 @@ function getNumbers (val1, val2) {
|
|||||||
return [val1Numeric, val2Numeric]
|
return [val1Numeric, val2Numeric]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRandomInt (min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = TestRunner
|
module.exports = TestRunner
|
||||||
|
|||||||
Reference in New Issue
Block a user