fix(接口测试): form-data请求体,参数同步有误
--bug=1045452 --user=陈建星 【接口测试】-API请求体参数名变更后,不开启删除无法对应的参数情况下同步,旧的参数依旧会被删除 https://www.tapd.cn/55049933/s/1566030
This commit is contained in:
parent
3a71d97845
commit
5165988f48
|
@ -303,7 +303,7 @@ public class HttpRequestParamDiffUtils {
|
|||
* @return
|
||||
*/
|
||||
public static Body syncBodyDiff(boolean isDeleteRedundantParam, Body sourceBody, Body targetBody) {
|
||||
if (sourceBody == null || targetBody == null || sourceBody.getBodyType() != targetBody.getBodyType()) {
|
||||
if (sourceBody == null || targetBody == null || !StringUtils.equals(sourceBody.getBodyType(), targetBody.getBodyType())) {
|
||||
return sourceBody;
|
||||
}
|
||||
Body.BodyType bodyType = EnumValidator.validateEnum(Body.BodyType.class, sourceBody.getBodyType());
|
||||
|
|
|
@ -766,6 +766,12 @@ public class HttpRequestParamDiffUtilsTests {
|
|||
sourceBody.getFormDataBody().getFormValues().add(formDataKV);
|
||||
result = HttpRequestParamDiffUtils.syncBodyDiff(true, sourceBody, targetBody);
|
||||
Assertions.assertEquals(result.getFormDataBody(), sourceBody.getFormDataBody());
|
||||
FormDataKV formDataKV2 = new FormDataKV();
|
||||
formDataKV2.setKey("key2");
|
||||
formDataKV2.setValue("value2");
|
||||
targetBody.getFormDataBody().getFormValues().add(formDataKV);
|
||||
result = HttpRequestParamDiffUtils.syncBodyDiff(true, sourceBody, targetBody);
|
||||
Assertions.assertNotEquals(result.getFormDataBody(), sourceBody.getFormDataBody());
|
||||
|
||||
sourceBody.setBodyType(Body.BodyType.WWW_FORM.name());
|
||||
targetBody.setBodyType(Body.BodyType.WWW_FORM.name());
|
||||
|
|
Loading…
Reference in New Issue