refactor(接口测试): 优化mock后置脚本设置变量模版

--bug=1032552 --user=王孝刚 【接口测试】github#27302,接口测试mock, 后置脚本python设置变量失败
https://www.tapd.cn/55049933/s/1433894
This commit is contained in:
wxg0103 2023-11-07 14:32:55 +08:00 committed by wxg0103
parent 5e866b2a22
commit b645407fa4
1 changed files with 13 additions and 1 deletions

View File

@ -140,7 +140,7 @@ export default {
children: [
{
title: i18n.t('api_test.request.processor.code_template_get_variable'),
value: 'vars.get("variable_name");',
value: this.getCustomVariable(),
},
{
title: i18n.t('api_test.request.processor.code_template_set_variable'),
@ -257,6 +257,18 @@ export default {
return returnScript;
},
//
getCustomVariable() {
let returnScript = '';
if (this.jsr223Processor) {
if (this.jsr223Processor.scriptLanguage === 'python') {
returnScript = 'vars["variable_name"]';
} else {
returnScript = 'vars.get("variable_name")';
}
}
return returnScript;
},
addTemplate(template) {
if (!this.jsr223Processor.script) {
this.jsr223Processor.script = '';