* Adjsut unit case.
This commit is contained in:
@@ -40,7 +40,13 @@ r($result) && p() && e('return false'); //使用正确的gitlabID、分支信息
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
|
||||
/* Delete branches with the same name. */
|
||||
$apiRoot = $gitlab->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/branches/{$_POST['branch']}");
|
||||
commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
|
||||
|
||||
$result = $gitlab->createBranch($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
|
||||
|
||||
@@ -40,7 +40,12 @@ r($result) && p() && e('return false'); //使用正确的gitlabID、标签信息
|
||||
|
||||
dao::$errors = array();
|
||||
$projectID = 1555;
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
|
||||
/* Delete branches with the same name. */
|
||||
$gitlab->apiDeleteTagPriv($gitlabID, $projectID, $_POST['tag_name']);
|
||||
$gitlab->apiDeleteTag($gitlabID, $projectID, $_POST['tag_name']);
|
||||
|
||||
$result = $gitlab->createTag($gitlabID, $projectID);
|
||||
if($result === true) $result = 'return true';
|
||||
r($result) && p() && e('return true'); //通过gitlabID,projectID,标签对象正确创建GitLab标签
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ pid=0
|
||||
|
||||
使用空的RepoUrl数据创建 >> fail
|
||||
使用正确的RepoUrl,错误的分支数据创建mr请求 >> fail
|
||||
使用源分支和目标分支一样的数据创建mr请求 >> success
|
||||
使用源分支和目标分支一样的数据创建mr请求 >> success
|
||||
使用正确的数据创建mr请求 >> success
|
||||
|
||||
*/
|
||||
@@ -28,7 +28,7 @@ r($result) && p() && e('fail'); //使用空的RepoUrl数据创建
|
||||
|
||||
dao::$errors = array();
|
||||
$_POST['data']['RepoUrl'] = 'http://192.168.1.161:51080/root/azalea723test.git';
|
||||
$_POST['data']['DiffMsg'] = '';
|
||||
$_POST['data']['DiffMsg'] = '';
|
||||
$_POST['data']['RepoSrcBranch'] = '';
|
||||
$_POST['data']['RepoDistBranch'] = '';
|
||||
$_POST['data']['MergeStatus'] = '1';
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 sonarqubeModel::apiDeleteProject();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
通过不正确的sonarqubeID、projectKey,删除SonarQube项目 >> return false
|
||||
正确的sonarqubeID,空的projectKey,删除SonarQube项目 >> The 'project' parameter is missing
|
||||
正确的sonarqubeID,不存在的projectKey,删除SonarQube项目 >> Project 'no_project' not found
|
||||
正确的sonarqubeID、projectKey,删除SonarQube项目 >> return true
|
||||
|
||||
*/
|
||||
|
||||
$sonarqube = $tester->loadModel('sonarqube');
|
||||
|
||||
$sonarqubeID = 0;
|
||||
$projectKey = '';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
if($result === false) $result = 'return false';
|
||||
r($result) && p() && e('return false'); //通过不正确的sonarqubeID、projectKey,删除SonarQube项目
|
||||
|
||||
$sonarqubeID = 2;
|
||||
$projectKey = '';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
r($result->errors) && p('0:msg') && e("The 'project' parameter is missing"); //正确的sonarqubeID,空的projectKey,删除SonarQube项目
|
||||
|
||||
$projectKey = 'no_project';
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
r($result->errors) && p('0:msg') && e("Project 'no_project' not found"); //正确的sonarqubeID,不存在的projectKey,删除SonarQube项目
|
||||
|
||||
$projectKey = 'new_project';
|
||||
list($apiRoot, $header) = $sonarqube->getApiBase($sonarqubeID);
|
||||
$url = sprintf($apiRoot, "projects/create?name=$projectKey&project=$projectKey");
|
||||
commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'POST'), $header);
|
||||
|
||||
$result = $sonarqube->apiDeleteProject($sonarqubeID, $projectKey);
|
||||
if($result === null) $result = 'return true';
|
||||
r($result) && p() && e("return true"); //正确的sonarqubeID、projectKey,删除SonarQube项目
|
||||
Reference in New Issue
Block a user