fix(接口测试): 修复接口测试环境中引用的文件找不到的问题

--bug=1018561 --user=宋天阳 【项目设置】环境配置设置变量,文件选用关联文件,启用环境提示异常
https://www.tapd.cn/55049933/s/1270703
This commit is contained in:
song-tianyang 2022-10-21 11:23:26 +08:00 committed by 刘瑞斌
parent f03c0ee8b0
commit 658e0e3e8d
1 changed files with 17 additions and 6 deletions

View File

@ -176,14 +176,25 @@ public class ElementUtil {
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ " + Translator.get("csv_no_exist") + " ]");
} else {
BodyFile file = item.getFiles().get(0);
String path = BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName();
if (StringUtils.equalsIgnoreCase(file.getStorage(), StorageEnums.FILE_REF.name())) {
path = ApiFileUtil.getFilePath(file);
}
if (!config.isOperating() && !new File(path).exists()) {
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ " + Translator.get("csv_no_exist") + " ]");
String fileId = item.getId();
boolean isRef = false;
String path = null;
if (StringUtils.equalsIgnoreCase(file.getStorage(), StorageConstants.FILE_REF.name())) {
isRef = true;
fileId = file.getFileId();
path = FileUtils.getFilePath(file);
} else {
path = BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName();
if (StringUtils.equalsIgnoreCase(file.getStorage(), StorageEnums.FILE_REF.name())) {
path = ApiFileUtil.getFilePath(file);
}
if (!config.isOperating() && !new File(path).exists()) {
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ " + Translator.get("csv_no_exist") + " ]");
}
}
csvDataSet.setProperty("filename", path);
csvDataSet.setProperty("isRef", isRef);
csvDataSet.setProperty("fileId", fileId);
}
csvDataSet.setIgnoreFirstLine(false);
csvDataSet.setProperty("shareMode", shareMode);