From 3dd55e8898d60494ee7c8602fe65e9dee69c72b7 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Tue, 12 Jul 2022 13:51:49 +0800 Subject: [PATCH] fix unit test issues --- .gitignore | 1 + cmd/command/main.go | 2 +- internal/command/action/case.go | 27 ++++++++++++++++- internal/command/action/checkout.go | 32 --------------------- internal/pkg/helper/script/parser.go | 4 +++ internal/server/modules/v1/domain/zentao.go | 1 + ui/src/locales/en-US.ts | 2 ++ ui/src/locales/zh-CN.ts | 3 ++ ui/src/views/result/FormResult.vue | 10 +++++-- 9 files changed, 45 insertions(+), 37 deletions(-) delete mode 100644 internal/command/action/checkout.go diff --git a/.gitignore b/.gitignore index 00fde7cc..597893c2 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ logs/ /.scannerwork/ /bin/ /log/ +/product1/ diff --git a/cmd/command/main.go b/cmd/command/main.go index bee77e34..fc35305e 100644 --- a/cmd/command/main.go +++ b/cmd/command/main.go @@ -102,7 +102,7 @@ func main() { case "ci": files := fileUtils.GetFilesFromParams(os.Args[2:]) if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { - action.CommitCases(files) + action.CheckIn(files) } case "cr": diff --git a/internal/command/action/case.go b/internal/command/action/case.go index 6682bcd8..efa53482 100644 --- a/internal/command/action/case.go +++ b/internal/command/action/case.go @@ -2,15 +2,40 @@ package action import ( commConsts "github.com/easysoft/zentaoatf/internal/pkg/consts" + commDomain "github.com/easysoft/zentaoatf/internal/pkg/domain" configHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/config" scriptHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/script" zentaoHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/zentao" + stdinUtils "github.com/easysoft/zentaoatf/pkg/lib/stdin" + stringUtils "github.com/easysoft/zentaoatf/pkg/lib/string" ) -func CommitCases(files []string) { +func CheckIn(files []string) { cases := scriptHelper.GetCaseByDirAndFile(files) config := configHelper.LoadByWorkspacePath(commConsts.ZtfDir) zentaoHelper.SyncToZentao(cases, config) } + +func Checkout(productId, moduleId, suiteId, taskId string, independentFile bool, scriptLang string) { + if (productId != "" || moduleId != "" || suiteId != "" || taskId != "") && scriptLang != "" { + //isReady = true + } else { + stdinUtils.InputForCheckout(&productId, &moduleId, &suiteId, &taskId, + &independentFile, &scriptLang) + } + + settings := commDomain.SyncSettings{ + ProductId: stringUtils.ParseInt(productId), + ModuleId: stringUtils.ParseInt(moduleId), + SuiteId: stringUtils.ParseInt(suiteId), + TaskId: stringUtils.ParseInt(taskId), + IndependentFile: independentFile, + Lang: scriptLang, + } + + config := configHelper.LoadByWorkspacePath(commConsts.ZtfDir) + + zentaoHelper.SyncFromZentao(settings, config, commConsts.WorkDir) +} diff --git a/internal/command/action/checkout.go b/internal/command/action/checkout.go deleted file mode 100644 index 9a665806..00000000 --- a/internal/command/action/checkout.go +++ /dev/null @@ -1,32 +0,0 @@ -package action - -import ( - commConsts "github.com/easysoft/zentaoatf/internal/pkg/consts" - commDomain "github.com/easysoft/zentaoatf/internal/pkg/domain" - configHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/config" - zentaoHelper "github.com/easysoft/zentaoatf/internal/pkg/helper/zentao" - stdinUtils "github.com/easysoft/zentaoatf/pkg/lib/stdin" - stringUtils "github.com/easysoft/zentaoatf/pkg/lib/string" -) - -func Checkout(productId, moduleId, suiteId, taskId string, independentFile bool, scriptLang string) { - if (productId != "" || moduleId != "" || suiteId != "" || taskId != "") && scriptLang != "" { - //isReady = true - } else { - stdinUtils.InputForCheckout(&productId, &moduleId, &suiteId, &taskId, - &independentFile, &scriptLang) - } - - settings := commDomain.SyncSettings{ - ProductId: stringUtils.ParseInt(productId), - ModuleId: stringUtils.ParseInt(moduleId), - SuiteId: stringUtils.ParseInt(suiteId), - TaskId: stringUtils.ParseInt(taskId), - IndependentFile: independentFile, - Lang: scriptLang, - } - - config := configHelper.LoadByWorkspacePath(commConsts.ZtfDir) - - zentaoHelper.SyncFromZentao(settings, config, commConsts.WorkDir) -} diff --git a/internal/pkg/helper/script/parser.go b/internal/pkg/helper/script/parser.go index eb66fe4e..bc73464f 100644 --- a/internal/pkg/helper/script/parser.go +++ b/internal/pkg/helper/script/parser.go @@ -8,6 +8,7 @@ import ( "github.com/easysoft/zentaoatf/pkg/consts" commonUtils "github.com/easysoft/zentaoatf/pkg/lib/common" fileUtils "github.com/easysoft/zentaoatf/pkg/lib/file" + "html" "io/ioutil" "path" "path/filepath" @@ -616,6 +617,9 @@ func GetCaseContent(stepObj commDomain.ZtfStep, seq string, independentFile bool expectContent = expectStr + stepContent = html.UnescapeString(stepContent) + expectContent = html.UnescapeString(expectContent) + return } diff --git a/internal/server/modules/v1/domain/zentao.go b/internal/server/modules/v1/domain/zentao.go index 606051c1..aefdc24d 100644 --- a/internal/server/modules/v1/domain/zentao.go +++ b/internal/server/modules/v1/domain/zentao.go @@ -10,6 +10,7 @@ type ZentaoRespData struct { } type ZentaoResultSubmitReq struct { + Title string `json:"title"` Seq string `json:"seq"` WorkspaceId int `json:"workspaceId"` ProductId int `json:"productId"` diff --git a/ui/src/locales/en-US.ts b/ui/src/locales/en-US.ts index cc78b07c..1a0a9c64 100644 --- a/ui/src/locales/en-US.ts +++ b/ui/src/locales/en-US.ts @@ -224,6 +224,8 @@ export default { 'open-in-explore': 'Open In Explore', 'open-in-terminal': 'Open In Terminal', + 'pls_select_task': 'Please select task', + 'or_input_task_name': 'Or input new task name', 'pls_select_workspace': 'Please select workspace.', 'pls_add_zentao_site': 'Please add zentao site.', 'pls_create_workspace': 'Please create workspace to continue.', diff --git a/ui/src/locales/zh-CN.ts b/ui/src/locales/zh-CN.ts index ece7b032..12b3c591 100644 --- a/ui/src/locales/zh-CN.ts +++ b/ui/src/locales/zh-CN.ts @@ -235,6 +235,9 @@ export default { 'open-in-explore': '在资源管理器中显示', 'open-in-terminal': '从此位置打开命令行', + 'pls_select_task': '请选择任务', + 'or_input_task_name': '或输入新任务标题', + 'pls_select_workspace': '请选择导出到的工作目录。', 'pls_add_zentao_site': '初次使用,请点击右上按钮新建禅道站点。', 'pls_create_workspace': '请点击右上角链接新建工作目录', diff --git a/ui/src/views/result/FormResult.vue b/ui/src/views/result/FormResult.vue index 67812705..9005cb97 100644 --- a/ui/src/views/result/FormResult.vue +++ b/ui/src/views/result/FormResult.vue @@ -4,10 +4,10 @@ @onCancel="close" @onOk="submit" :title="t('submit_result_to_zentao')" - :contentStyle="{width: '300px'}" + :contentStyle="{width: '500px'}" > -
- + +
+ + + + -- GitLab