-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 脚本开放管理类API #2318 #2578
feat: 脚本开放管理类API #2318 #2578
Conversation
* 失败响应通用设置 | ||
*/ | ||
public static ResponseSpecification failResponseSpec() { | ||
ResponseSpecBuilder builder = new ResponseSpecBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个响应并不通用,这个方法有点误导
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去掉了,errorCode调用处传入
req.setScriptId(script.getScriptId()); | ||
Operations.deletePublicScript(req); | ||
// 清理脚本版本 | ||
EsbDeletePublicScriptVersionV3Req req1 = new EsbDeletePublicScriptVersionV3Req(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多余的操作,删除脚本也会同时删除脚本版本
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已去除
req.setVersion("v2"); | ||
req.setVersionDesc("v2_desc"); | ||
if (CollectionUtils.isEmpty(createdPublicScriptList)){ | ||
testCreatePublicScript(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试用例之间最好能保持独立行。这里可以调用 Operations 里边的通用方法创建一个公共脚本,然后基于这个创建好的脚本来新建脚本,个人觉得会更合理一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,测试用例之间不应该有依赖。已改
.spec(ApiUtil.successResponseSpec()) | ||
.body("data", notNullValue()) | ||
.body("data.id", greaterThan(0)) | ||
.body("data.script_id", notNullValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不够严谨,这个必须等同与请求传入的 script_id. 其他地方类似
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已改
req.setContent(SHELL_SCRIPT_CONTENT_BASE64); | ||
req.setVersion("v2"); | ||
req.setVersionDesc("v2_desc"); | ||
if (CollectionUtils.isEmpty(createdPublicScriptList)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试用例之间最好能保持独立行。这里可以调用 Operations 里边的通用方法创建一个公共脚本,然后基于这个创建好的脚本来新建脚本,个人觉得会更合理一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已改
.body("data.script_version_id", equalTo(req.getScriptVersionId().intValue())) | ||
.body("data.script_id", equalTo(req.getScriptId())); | ||
} else { | ||
given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要在一个测试用例里边测试两种分支。if/else 的可以拆分为两个测试用例
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
单独出来了
void testPublishPublicScriptVersion() { | ||
EsbScriptVersionDetailV3DTO scriptVersionDTO; | ||
if (CollectionUtils.isNotEmpty(createdPublicScriptList)) { | ||
scriptVersionDTO = createdPublicScriptList.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createdPublicScriptList 这个变量仅仅用于最终删除使用。如果多个测试用例并发的执行的话,createdPublicScriptList的数据和状态都是不确定的,容易有并发问题。相关使用 createdPublicScriptList 的地方可以修改下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已改
|
||
// 版本号有特殊字符, 创建失败 | ||
req.setVersion("|"); | ||
given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) | ||
.body(JsonUtil.toJson(req)) | ||
.post(APIV3Urls.CREATE_PUBLIC_SCRIPT) | ||
.then() | ||
.spec(ApiUtil.failResponseSpec()); | ||
.spec(ApiUtil.failResponseSpec(ErrorCode.BAD_REQUEST)); | ||
createdPublicScriptList.add(createdPublicScript); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
创建好之后需要立即放入 createdPublicScriptList, 避免中间过程报错导致已创建的脚本没有被清理。其他地方类似
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
No description provided.