Skip to content

Commit 4373b5b

Browse files
committed
* [fix] imp ci submit case
Signed-off-by: ysicing <i@ysicing.me>
1 parent 14d502f commit 4373b5b

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# CHANGELOG.md
22

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

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

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

internal/pkg/helper/zentao/case.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ func CommitCase(productId string, caseId int, title string, steps []commDomain.Z
4242
if !strings.Contains(err.Error(), "404") {
4343
return
4444
}
45-
if len(productId) == 0 {
46-
logUtils.Info("not found productId, like: pid=1")
47-
return fmt.Errorf("not found productId, like: pid=1")
45+
logUtils.Info(i118Utils.Sprintf("case_not_found", caseId))
46+
if len(productId) > 0 {
47+
// 创建cases
48+
logUtils.Info(i118Utils.Sprintf("auto_create_case", productId, caseId))
49+
_, err = CreateCase(productId, title, steps, script, config)
50+
return err
4851
}
49-
// 创建cases
50-
_, err = CreateCase(productId, title, steps, script, config)
52+
5153
return
5254
}
5355

@@ -138,8 +140,7 @@ func CreateCase(productId, title string, steps []commDomain.ZentaoCaseStep, scri
138140
err = ZentaoRequestErr(url, commConsts.ResponseParseErr.Message)
139141
return
140142
}
141-
logUtils.Infof(i118Utils.Sprintf("success_to_create_case", title) + "\n")
142-
143+
logUtils.Infof(i118Utils.Sprintf("success_to_create_case", productId, title) + "\n")
143144
return
144145
}
145146

internal/pkg/helper/zentao/comm.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ func ZentaoRequestErr(errs ...interface{}) (err error) {
3333
arr = append(arr, fmt.Sprintf("%v", item))
3434
}
3535

36-
msg := i118Utils.Sprintf("fail_to_request_zentao", strings.Join(arr, ", "))
37-
36+
msg := strings.Join(arr, ", ")
37+
if strings.Contains(msg, "403") {
38+
msg = i118Utils.Sprintf("fail_to_request_zentao_403")
39+
} else {
40+
msg = i118Utils.Sprintf("fail_to_request_zentao", msg)
41+
}
3842
err = errors.New(msg)
3943
logUtils.Infof(color.RedString(err.Error()))
4044

res/server/en/messages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@
371371
},
372372
{
373373
"id": "fail_to_request_zentao",
374+
"translation": "Zentao request failed, return: %s."
375+
},
376+
{
377+
"id": "fail_to_request_zentao_403",
374378
"translation": "Zentao request failed, return: %s. If request 403, please precheck account permission by ztf login"
375379
},
376380
{
@@ -789,6 +793,18 @@
789793
{
790794
"id": "checkout_success",
791795
"translation": "Checkout success."
796+
},
797+
{
798+
"id": "case_not_found",
799+
"translation": "No found any case %v."
800+
},
801+
{
802+
"id": "auto_create_case",
803+
"translation": "Product %v create case %v."
804+
},
805+
{
806+
"id": "success_to_create_case",
807+
"translation": "Product %v create case success, title %v."
792808
}
793809
]
794810
}

res/server/zh/messages.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@
361361
},
362362
{
363363
"id": "fail_to_request_zentao",
364+
"translation": "禅道请求失败,返回:%s。"
365+
},
366+
{
367+
"id": "fail_to_request_zentao_403",
364368
"translation": "禅道请求失败,返回:%s。如果是403问题, 可以先用ztf login检测是否是权限问题"
365369
},
366370
{
@@ -778,6 +782,18 @@
778782
{
779783
"id": "checkout_success",
780784
"translation": "同步完成"
785+
},
786+
{
787+
"id": "case_not_found",
788+
"translation": "未发现用例 %v"
789+
},
790+
{
791+
"id": "auto_create_case",
792+
"translation": "产品ID %v 尝试创建用例 %v"
793+
},
794+
{
795+
"id": "success_to_create_case",
796+
"translation": "产品ID %v 创建用例成功, 标题为 %v"
781797
}
782798
]
783799
}

0 commit comments

Comments
 (0)