Skip to content

Commit

Permalink
* [fix] imp ci submit case
Browse files Browse the repository at this point in the history
Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Aug 29, 2024
1 parent 14d502f commit 4373b5b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# CHANGELOG.md

## 3.3.0-beta.3 (2024-08-26)
## 3.3.0-beta.3 (2024-08-29)

- 优化部分异常情况下错误提示
- 新增login子命令排查ztf命令行与禅道通信问题
- 修复部分错误表述信息
- 更新demo示例,统一使用新格式用例
- 新增`ZTF_DEBUG`环境变量,用于调试模式
- 优化`ci`,提示信息更加友好,测试支持当用例不存在时创建用例(需要指定产品`-p`)

## 3.3.0-beta.2 (2024-08-14)

Expand Down
15 changes: 8 additions & 7 deletions internal/pkg/helper/zentao/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ func CommitCase(productId string, caseId int, title string, steps []commDomain.Z
if !strings.Contains(err.Error(), "404") {
return
}
if len(productId) == 0 {
logUtils.Info("not found productId, like: pid=1")
return fmt.Errorf("not found productId, like: pid=1")
logUtils.Info(i118Utils.Sprintf("case_not_found", caseId))
if len(productId) > 0 {
// 创建cases
logUtils.Info(i118Utils.Sprintf("auto_create_case", productId, caseId))
_, err = CreateCase(productId, title, steps, script, config)
return err
}
// 创建cases
_, err = CreateCase(productId, title, steps, script, config)

return
}

Expand Down Expand Up @@ -138,8 +140,7 @@ func CreateCase(productId, title string, steps []commDomain.ZentaoCaseStep, scri
err = ZentaoRequestErr(url, commConsts.ResponseParseErr.Message)
return
}
logUtils.Infof(i118Utils.Sprintf("success_to_create_case", title) + "\n")

logUtils.Infof(i118Utils.Sprintf("success_to_create_case", productId, title) + "\n")
return
}

Expand Down
8 changes: 6 additions & 2 deletions internal/pkg/helper/zentao/comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ func ZentaoRequestErr(errs ...interface{}) (err error) {
arr = append(arr, fmt.Sprintf("%v", item))
}

msg := i118Utils.Sprintf("fail_to_request_zentao", strings.Join(arr, ", "))

msg := strings.Join(arr, ", ")
if strings.Contains(msg, "403") {
msg = i118Utils.Sprintf("fail_to_request_zentao_403")
} else {
msg = i118Utils.Sprintf("fail_to_request_zentao", msg)
}
err = errors.New(msg)
logUtils.Infof(color.RedString(err.Error()))

Expand Down
16 changes: 16 additions & 0 deletions res/server/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@
},
{
"id": "fail_to_request_zentao",
"translation": "Zentao request failed, return: %s."
},
{
"id": "fail_to_request_zentao_403",
"translation": "Zentao request failed, return: %s. If request 403, please precheck account permission by ztf login"
},
{
Expand Down Expand Up @@ -789,6 +793,18 @@
{
"id": "checkout_success",
"translation": "Checkout success."
},
{
"id": "case_not_found",
"translation": "No found any case %v."
},
{
"id": "auto_create_case",
"translation": "Product %v create case %v."
},
{
"id": "success_to_create_case",
"translation": "Product %v create case success, title %v."
}
]
}
16 changes: 16 additions & 0 deletions res/server/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@
},
{
"id": "fail_to_request_zentao",
"translation": "禅道请求失败,返回:%s。"
},
{
"id": "fail_to_request_zentao_403",
"translation": "禅道请求失败,返回:%s。如果是403问题, 可以先用ztf login检测是否是权限问题"
},
{
Expand Down Expand Up @@ -778,6 +782,18 @@
{
"id": "checkout_success",
"translation": "同步完成"
},
{
"id": "case_not_found",
"translation": "未发现用例 %v"
},
{
"id": "auto_create_case",
"translation": "产品ID %v 尝试创建用例 %v"
},
{
"id": "success_to_create_case",
"translation": "产品ID %v 创建用例成功, 标题为 %v"
}
]
}

0 comments on commit 4373b5b

Please sign in to comment.