* Adjsut unit cases.

This commit is contained in:
liyuchun
2022-01-27 11:16:10 +08:00
parent 7234b58c3f
commit 4b9ee0cc3c
17 changed files with 204 additions and 26 deletions
+6
View File
@@ -265,6 +265,12 @@ class mrModel extends model
$MR->createdBy = $this->app->user->account;
$MR->createdDate = date('Y-m-d H:i:s');
if($MR->sourceProject == $MR->targetProject and $MR->sourceBranch == $MR->targetBranch)
{
dao::$errors[] = $this->lang->mr->errorLang[1];
return false;
}
$result = $this->checkSameOpened($MR->gitlabID, $MR->sourceProject, $MR->sourceBranch, $MR->targetProject, $MR->targetBranch);
if($result['result'] == 'fail')
{
+1 -2
View File
@@ -20,8 +20,7 @@
<table class='table table-form'>
<tr>
<th><?php echo $lang->gitlab->common;?></th>
<!-- Use `array('') + $gitlabHosts` here because of this field must be changed when creating this MR. -->
<td class='required'><?php echo html::select('gitlabID', array('') + $gitlabHosts, '', "class='form-control'");?></td>
<td class='required'><?php echo html::select('gitlabID', array('') + $gitlabHosts, '', "class='form-control chosen'");?></td>
</tr>
<tr>
<th style="white-space: nowrap;"><?php echo $lang->mr->sourceProject;?></th>
+146
View File
@@ -0,0 +1,146 @@
title: table zt_job
desc: "构建任务"
author: automated export
version: "1.0"
fields:
- field: id
note: "ID"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: name
note: "名称"
range: 1-10000
prefix: "这是一个Job"
postfix: ""
loop: 0
format: ""
- field: repo
note: "代码库"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: product
note: "关联产品"
range: 1-10000
prefix: ""
postfix: ""
loop: 0
format: ""
- field: frame
note: "工具/框架"
range: junit,testng,phpunit,pytest,jtest,cppunit,gtest,qtest
prefix: ""
postfix: ""
loop: 0
format: ""
- field: engine
note: "引擎"
range: jenkins,gitlab
- field: triggerType
note: "触发方式"
range: tag,commit,schedule
prefix: ""
postfix: ""
loop: 0
format: ""
- field: svnDir
note: "SVN监控路径"
range: caselib,effort,git,mail,output
prefix: "/module/"
postfix: ""
loop: 0
format: ""
- field: atDay
note: "自定义日期"
range: 0-6
prefix: ""
postfix: ""
loop: 0
format: ""
- field: atTime
note: "执行时间"
range: "22:05"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: customParam
note: "自定义构建参数"
range: ''
prefix: "["
postfix: "]"
loop: 0
format: ""
- field: comment
note: "匹配关键字"
range: a-z
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdBy
note: "创建者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: createdDate
note: "创建日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: editedBy
note: "编辑者"
from: common.user.v1.yaml
use: user
prefix: ""
postfix: ""
loop: 0
format: ""
- field: editedDate
note: "编辑日期"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: lastExec
note: "最后执行时间"
from: common.date.v1.yaml
use: dateA
prefix: ""
postfix: ""
loop: 0
format: ""
- field: lastStatus
note: "最后执行状态"
range: "a-z"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: lastTag
note: "最后执行标签"
range: "a-z"
prefix: ""
postfix: ""
loop: 0
format: ""
- field: deleted
note: "是否删除"
range: 0
prefix: ""
postfix: ""
loop: 0
format: ""
+4
View File
@@ -16,5 +16,9 @@ fields:
range: 1
- field: extra
range: 42
- field: preMerge
range: 1
- field: job
range: 1
- field: deleted
range: 0
+1
View File
@@ -22,4 +22,5 @@ $builder->release = array('rows' => 8, 'extends' => array('release'));
$builder->pipeline = array('rows' => 2, 'extends' => array('pipeline'));
$builder->repo = array('rows' => 1, 'extends' => array('repo'));
$builder->job = array('rows' => 2, 'extends' => array('job'));
$builder->mr = array('rows' => 1, 'extends' => array('mr'));
+3
View File
@@ -38,6 +38,9 @@ fields:
postfix: ""
loop: 0
format: ""
- field: engine
note: "引擎"
range: jenkins,gitlab
- field: jkHost
note: "Jenkins服务器"
range: 1-10000
+2 -2
View File
@@ -30,7 +30,7 @@ $branch->branch = 'test_branch17';
$branch->ref = 'master';
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
if($result === null) $result = 'return null';
r($result) && p() && e('return false'); //使用空的gitlabID、projectID,正确的分支对象创建GitLab分支
r($result) && p() && e('return null'); //使用空的gitlabID、projectID,正确的分支对象创建GitLab分支
$gitlabID = 1;
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('404 Project Not Found'); //使用正确的gitlabID、分支信息,错误的projectID创建分支
@@ -39,5 +39,5 @@ $projectID = 1555;
$result = $gitlab->apiCreateBranch($gitlabID, $projectID, $branch);
if(!empty($result->name) and $result->name == $branch->branch) $result = true;
if(!empty($result->message) and $result->message == 'Branch already exists') $result = true;
r($result) && p() && e(1); //通过gitlabID,projectID,分支对象正确创建GitLab分支
r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
r($gitlab->apiCreateBranch($gitlabID, $projectID, $branch)) && p('message') && e('Branch already exists'); //使用重复的分支信息创建分支
+1 -1
View File
@@ -41,6 +41,6 @@ r($result) && p() && e('return false'); //使用正确的gitlabID、保护分支
$projectID = 966;
$gitlab->apiDeleteBranchPriv($gitlabID, $projectID, $branch->name);
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('name') && e($branch->name); //通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('name') && e('master'); //通过gitlabID,projectID,保护分支对象正确创建GitLab保护分支
r($gitlab->apiCreateBranchPriv($gitlabID, $projectID, $branch)) && p('message') && e("Protected branch 'master' already exists"); //使用重复的保护分支信息创建保护分支
+3 -3
View File
@@ -21,12 +21,12 @@ $gitlab = $tester->loadModel('gitlab');
$gitlabID = 1;
$projectID = 1552;
$result = $gitlab->apiGetBranches($gitlabID, $projectID);
r(isset(array_shift($result)->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab分支列表
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab分支数量
r(isset(array_shift($result)->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab分支列表
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab分支数量
$gitlabID = 1;
$projectID = 959;
r(count($gitlab->apiGetBranches($gitlabID, $projectID))) && p() && e(0); //当前项目没有分支时,获取GitLab分支列表
r(count($gitlab->apiGetBranches($gitlabID, $projectID))) && p() && e('0'); //当前项目没有分支时,获取GitLab分支列表
$gitlabID = 1;
$projectID = 0;
+4 -4
View File
@@ -8,7 +8,7 @@ title=测试 gitlabModel::apiGetBranchPrivs();
cid=1
pid=1
获取指定项目下受保护分支列表 >> master
获取指定项目下受保护分支列表 >> master
获取指定项目下受保护分支数量 >> 3
获取无保护分支的项目下受保护分支数量 >> 0
通过不存在projectID,获取受保护分支列表 >> 404 Project Not Found
@@ -23,11 +23,11 @@ $projectID = 961;
$keyword = '';
$orderBy = 'name_desc';
$result = $gitlab->apiGetBranchPrivs($gitlabID, $projectID, $keyword, $orderBy);
r($result) && p('master:name') && e('master'); //获取指定项目下受保护分支列表
r(count($result)) && p() && e(3); //获取指定项目下受保护分支数量
r($result) && p('master:name') && e('master'); //获取指定项目下受保护分支列表
r(count($result)) && p() && e('3'); //获取指定项目下受保护分支数量
$projectID = 1572;
r(count($gitlab->apiGetBranchPrivs($gitlabID, $projectID))) && p() && e(0); //获取无保护分支的项目下受保护分支数量
r(count($gitlab->apiGetBranchPrivs($gitlabID, $projectID))) && p() && e('0'); //获取无保护分支的项目下受保护分支数量
$projectID = 0;
r($gitlab->apiGetBranchPrivs($gitlabID, $projectID)) && p('message') && e('404 Project Not Found'); //通过不存在projectID,获取受保护分支列表
+3 -3
View File
@@ -21,12 +21,12 @@ $gitlab = $tester->loadModel('gitlab');
$gitlabID = 1;
$projectID = 1552;
$result = $gitlab->apiGetTagPrivs($gitlabID, $projectID);
r(isset(array_shift($result)->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护列表
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签保护数量
r(isset(array_shift($result)->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签保护列表
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签保护数量
$gitlabID = 1;
$projectID = 1570;
r(count($gitlab->apiGetTagPrivs($gitlabID, $projectID))) && p() && e(0); //当前项目没有标签保护时,获取GitLab标签保护列表
r(count($gitlab->apiGetTagPrivs($gitlabID, $projectID))) && p() && e('0'); //当前项目没有标签保护时,获取GitLab标签保护列表
$gitlabID = 1;
$projectID = 0;
+3 -3
View File
@@ -24,12 +24,12 @@ $gitlab = $tester->loadModel('gitlab');
$gitlabID = 1;
$projectID = 1552;
$result = $gitlab->apiGetTags($gitlabID, $projectID);
r(isset($result[0]->name)) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签列表
r(count($result) > 0) && p() && e(1); //通过gitlabID,projectID,获取GitLab标签数量
r(isset($result[0]->name)) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签列表
r(count($result) > 0) && p() && e('1'); //通过gitlabID,projectID,获取GitLab标签数量
$gitlabID = 1;
$projectID = 1570;
r(count($gitlab->apiGetTags($gitlabID, $projectID))) && p() && e(0); //当前项目没有标签时,获取GitLab标签列表
r(count($gitlab->apiGetTags($gitlabID, $projectID))) && p() && e('0'); //当前项目没有标签时,获取GitLab标签列表
$gitlabID = 1;
$projectID = 0;
+1 -3
View File
@@ -16,15 +16,13 @@ pid=1
*/
global $lang;
$gitlab = $tester->loadModel('gitlab');
$gitlabID = 0;
$projectID = 0;
$gitlab->createTagPriv($gitlabID, $projectID);
r(dao::getError()) && p('name:0') && e($lang->gitlab->tag->emptyPrivNameError); //使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签
r(dao::getError()) && p('name:0') && e('标签不能为空'); //使用空的gitlabID,projectID,保护标签对象创建GitLab保护标签
$_POST['name'] = 'test_tag1';
$_POST['create_access_level'] = '40';
+11 -1
View File
@@ -15,6 +15,7 @@ pid=0
*/
global $lang;
$mrModel = $tester->loadModel('mr');
$_POST = array(
@@ -40,12 +41,21 @@ dao::$errors = array();
$_POST['data']['RepoSrcBranch'] = 'master';
$_POST['data']['RepoDistBranch'] = 'master';
$result = $mrModel->apiCreate();
if($result) $result = 'success';
if(!$result and dao::isError())
{
$errors = dao::getError();
if($errors[0] == $lang->mr->errorLang[1]) $result = 'success';
}
r($result) && p() && e('success'); //使用源分支和目标分支一样的数据创建mr请求
dao::$errors = array();
$_POST['data']['RepoSrcBranch'] = 'branch-08';
$_POST['data']['RepoDistBranch'] = 'master';
$result = $mrModel->apiCreate();
if(dao::isError())
{
$errors = dao::getError();
$result = preg_match('/[存在另外一个同样的合并请求在源项目分支中,存在重复并且未关闭的合并请求]: ID([0-9]+)/', $errors[0], $matches); //检查错误原因是否是已存在一样的mr请求
}
if($result) $result = 'success';
r($result) && p() && e('success'); //使用正确的数据创建mr请求
+11
View File
@@ -28,6 +28,17 @@ $sourceProject = '42';
$sourceBranch = 'branch-08';
$targetProject = '42';
$targetBranch = 'master';
$_POST['gitlabID'] = $gitlabID;
$_POST['title'] = 'test_create';
$_POST['description'] = 'test_create';
$_POST['repoID'] = 1;
$_POST['assignee'] = '';
$_POST['removeSourceBranch'] = '1';
$_POST['sourceProject'] = $sourceProject;
$_POST['sourceBranch'] = $sourceBranch;
$_POST['targetProject'] = $targetProject;
$_POST['targetBranch'] = $targetBranch;
$result = $mrModel->create();
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
if(isset($result->iid)) $result = 'success';
r($result) && p() && e('success'); //使用正确的gitlabID, sourceProject,sourceBranch,targetProject,targetBranch
+1 -1
View File
@@ -19,7 +19,7 @@ $MRID = 1;
$_POST = array();
$_POST['targetBranch'] = 'master';
$_POST['title'] = 'Test MR';
$_POST['description'] = date("Y-m-d H:i:s");
$_POST['description'] = '2022-01-31 23:59:59';
$_POST['repoID'] = 1;
$_POST['assignee'] = '';
$_POST['removeSourceBranch'] = '0';
+3 -3
View File
@@ -19,12 +19,12 @@ $sonarqube = $tester->loadModel('sonarqube');
$sonarqubeID = 2;
$result = $sonarqube->apiGetProjects($sonarqubeID);
r(isset($result[0]->name)) && p() && e(1); //通过sonarqubeID,获取SonarQube项目列表
r(count($result) > 0) && p() && e(1); //通过sonarqubeID,获取SonarQube项目数量
r(isset($result[0]->name)) && p() && e('1'); //通过sonarqubeID,获取SonarQube项目列表
r(count($result) > 0) && p() && e('1'); //通过sonarqubeID,获取SonarQube项目数量
$keyword = '02';
$result = $sonarqube->apiGetProjects($sonarqubeID, $keyword);
r(strpos($result[0]->name, '02') !== false) && p() && e(1); //通过sonarqubeID,关键字,搜索获取SonarQube项目
r(strpos($result[0]->name, '02') !== false) && p() && e('1'); //通过sonarqubeID,关键字,搜索获取SonarQube项目
$sonarqubeID = 0;
$result = $sonarqube->apiGetProjects($sonarqubeID);