提交 9d3350af 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix issues

上级 cb5b3fe8
......@@ -698,14 +698,10 @@ func ScriptToExpectName(file string) string {
// return runName
//}
func GetCaseInfo(file string) (bool, int, int, string) {
var caseId int
var productId int
var title string
func GetCaseInfo(file string) (pass bool, caseId, productId int, title string) {
content := fileUtils.ReadFile(file)
isOldFormat := strings.Index(content, "[esac]") > -1
pass := CheckFileContentIsScript(content)
pass = CheckFileContentIsScript(content)
if !pass {
return false, caseId, productId, title
}
......@@ -745,7 +741,11 @@ func GetCaseInfo(file string) (bool, int, int, string) {
title = strings.TrimSpace(arr[1])
}
return pass, caseId, productId, title
if caseId <= 0 {
pass = false
}
return
}
//func ReadScriptCheckpoints(file string) ([]string, [][]string) {
......
......@@ -29,6 +29,11 @@ func CommitCase(caseId int, title string,
return
}
_, err = GetCaseById(config.Url, caseId)
if err != nil {
return
}
uri := fmt.Sprintf("/testcases/%d", caseId)
url := GenApiUrl(uri, nil, config.Url)
......
......@@ -66,15 +66,17 @@ func SyncFromZentao(settings commDomain.SyncSettings, config commDomain.Workspac
return
}
func SyncToZentao(cases []string, config commDomain.WorkspaceConf) (err error) {
count := 0
func SyncToZentao(cases []string, config commDomain.WorkspaceConf) (count int, err error) {
for _, cs := range cases {
pass, id, _, title := scriptHelper.GetCaseInfo(cs)
if !pass {
continue
}
if pass && id > 0 {
steps, _ := scriptHelper.GetStepAndExpectMap(cs)
CommitCase(id, title, steps, config)
steps, _ := scriptHelper.GetStepAndExpectMap(cs)
err = CommitCase(id, title, steps, config)
if err == nil {
count++
}
}
......
......@@ -246,18 +246,20 @@ func (c *TestScriptCtrl) SyncToZentao(ctx iris.Context) {
site, _ := c.SiteService.Get(uint(currSiteId))
config := configHelper.LoadBySite(site)
totalNum := 0
successNum := 0
for _, set := range sets {
// workspaceId := set.WorkspaceId
// workspace, _ := c.WorkspaceService.Get(uint(workspaceId))
err := zentaoHelper.SyncToZentao(set.Cases, config)
if err != nil {
ctx.JSON(c.ErrResp(commConsts.CommErr, err.Error()))
return
}
totalNum += len(set.Cases)
count, _ := zentaoHelper.SyncToZentao(set.Cases, config)
successNum += count
}
ctx.JSON(c.SuccessResp(nil))
ctx.JSON(c.SuccessResp(iris.Map{
"total": totalNum,
"success": successNum,
}))
}
// Get 根据报告获取用例编号的列表
......
......@@ -184,7 +184,7 @@ export default {
'extract_success': 'Extract comments to test steps and checkpoints successfully.',
'extract_none': 'Not found any test steps in script comments.',
'extract_fail': 'Extract comments to test steps and checkpoints failed.',
'sync_success': 'Sync successfully.',
'sync_success': 'Success to sync {success} cases to Zentao, ignore {ignore} cases.',
'sync_fail': 'Sync failed.',
'by_workspace': 'By WorkDir',
'by_module': 'By Module',
......
......@@ -191,7 +191,7 @@ export default {
'extract_success': '提取注释为测试步骤和验证点成功。',
'extract_none': '脚本中未发现测试步骤。',
'extract_fail': '提取注释为测试步骤和验证点失败。',
'sync_success': '同步成功',
'sync_success': '成功同步{success}个用例到禅道,忽略{ignore}个。',
'sync_fail': '同步失败',
'by_workspace': '按目录',
'by_module': '按模块',
......
......@@ -467,8 +467,6 @@ const menuClick = (menuKey: string, targetId: number) => {
if(menuKey === 'exec'){
execScript(contextNodeData)
}else if(menuKey == 'sync-from-zentao'){
syncFromZentao(contextNodeData)
} else if (menuKey === 'copy' || menuKey === 'cut') {
clipboardAction.value = menuKey
clipboardData.value = contextNodeData
......@@ -498,7 +496,9 @@ const menuClick = (menuKey: string, targetId: number) => {
store.dispatch('Script/deleteScript', contextNodeData.id)
},
});
}else if(menuKey === 'sync-to-zentao'){
} else if(menuKey == 'sync-from-zentao'){
syncFromZentao(contextNodeData)
} else if(menuKey === 'sync-to-zentao'){
checkinCases(contextNodeData)
} else {
clipboardAction.value = ''
......@@ -525,7 +525,12 @@ const checkinCases = (node) => {
const workspaceWithScripts = genWorkspaceToScriptsMap(fileNodes)
store.dispatch('Script/syncToZentao', workspaceWithScripts).then((resp => {
if (resp.code === 0) {
notification.success({message: t('sync_success')});
notification.success({message:
t('sync_success', {
success: resp.data.success,
ignore: resp.data.total - resp.data.success
}
)});
} else {
notification.error({message: t('sync_fail'), description: resp.data.msg});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册