* [unittest] adjust gitlab unit test case.
This commit is contained in:
@@ -12,17 +12,24 @@ cid=1
|
||||
|
||||
- 使用repoID为1,不存在的项目id推送webhook @0
|
||||
- 使用repoID为1,存在的项目id推送webhook @1
|
||||
- 使用repoID为1,异常的项目id推送webhook @1
|
||||
- 使用repoID为2,不存在的项目id推送webhook @0
|
||||
- 使用repoID为2,存在的项目id推送webhook @1
|
||||
|
||||
*/
|
||||
|
||||
zenData('pipeline')->gen(5);
|
||||
zenData('repo')->gen(1);
|
||||
zenData('repo')->gen(2);
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$repoID = 1;
|
||||
$token = '';
|
||||
$_SERVER['REQUEST_URI'] = 'http://unittest/';
|
||||
|
||||
r($gitlab->addPushWebhookTest($repoID, $token)) && p() && e('0'); //使用repoID为1,不存在的项目id推送webhook
|
||||
r($gitlab->addPushWebhookTest($repoID, $token, 2)) && p() && e('1'); //使用repoID为1,存在的项目id推送webhook
|
||||
r($gitlab->addPushWebhookTest(1, $token)) && p() && e('0'); //使用repoID为1,不存在的项目id推送webhook
|
||||
r($gitlab->addPushWebhookTest(1, $token, 2)) && p() && e('1'); //使用repoID为1,存在的项目id推送webhook
|
||||
r($gitlab->addPushWebhookTest(1, $token, -1)) && p() && e('0'); //使用repoID为1,异常的项目id推送webhook
|
||||
|
||||
r($gitlab->addPushWebhookTest(2, $token)) && p() && e('0'); //使用repoID为2,不存在的项目id推送webhook
|
||||
r($gitlab->addPushWebhookTest(2, $token, 2)) && p() && e('1'); //使用repoID为2,存在的项目id推送webhook
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ $user = new stdclass();
|
||||
$user->name = '';
|
||||
$user->username = 'apiuser17';
|
||||
$user->email = 'apiuser17@test.com';
|
||||
$user->password = '12345678';
|
||||
$user->password = '123Qwe!@#';
|
||||
|
||||
r($gitlab->apiCreateUser($gitlabID, $user)) && p() && e('0'); //使用空的name创建gitlab用户
|
||||
|
||||
@@ -41,4 +41,4 @@ if(!empty($result->name) and $result->name == $user->name) $result = true;
|
||||
if(!empty($result->message) and $result->message == 'Email has already been taken') $result = true;
|
||||
r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab用户
|
||||
|
||||
r( $gitlab->apiCreateUser($gitlabID, $user)) && p('message') && e('Email has already been taken'); //使用重复的信息创建gitlab用户
|
||||
r($gitlab->apiCreateUser($gitlabID, $user)) && p('message') && e('Email has already been taken'); //使用重复的信息创建gitlab用户
|
||||
|
||||
@@ -18,6 +18,10 @@ cid=1
|
||||
|
||||
zenData('pipeline')->gen(5);
|
||||
|
||||
global $app;
|
||||
$app->rawModule = 'gitlab';
|
||||
$app->rawMethod = 'browse';
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
$gitlab->app->moduleName = 'gitlab';
|
||||
$gitlab->app->methodName = 'browse';
|
||||
@@ -36,7 +40,7 @@ r(count($result['projects']) > 0) && p() && e('1'); //通过gitlabID,获取
|
||||
|
||||
$gitlabID = 0;
|
||||
$result = $gitlab->apiGetProjectsPager($gitlabID, $keyword, $orderBy, $pager);
|
||||
if(empty($result)) $result = 'return empty';
|
||||
if(empty($result) || empty($result['projects'])) $result = 'return empty';
|
||||
r($result) && p() && e('return empty'); //当gitlabID为0时,获取GitLab项目列表
|
||||
|
||||
$gitlabID = 1;
|
||||
@@ -46,4 +50,4 @@ r($result['projects']) && p('1:name') && e('testHtml'); //通过gitlabID,按项
|
||||
|
||||
$keyword = 'private';
|
||||
$result = $gitlab->apiGetProjectsPager($gitlabID, $keyword, $orderBy, $pager);
|
||||
r($result['projects']) && p('0:name') && e('privateProject'); //通过gitlabID,搜索字符'private'获取GitLab项目列表
|
||||
r($result['projects']) && p('0:name') && e('privateProject'); //通过gitlabID,搜索字符'private'获取GitLab项目列表
|
||||
|
||||
@@ -20,6 +20,10 @@ cid=1
|
||||
zenData('pipeline')->gen(5);
|
||||
zenData('repo')->loadYaml('repo')->gen(5);
|
||||
|
||||
global $app;
|
||||
$app->rawModule = 'gitlab';
|
||||
$app->rawMethod = 'browse';
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
@@ -56,4 +60,4 @@ $options = array(CURLOPT_CUSTOMREQUEST => 'PUT');
|
||||
r($gitlabTest->apiPostTest($host, $api, $user, $options)) && p() && e('success'); //用host url 发送一个请求
|
||||
r($gitlabTest->apiPostTest($hostID, $api, $user, $options)) && p() && e('success'); //用host ID 发送一个请求
|
||||
r($gitlabTest->apiPostTest($host2, $api, $user, $options)) && p() && e('return null'); //用不合规范的host url 发送一个请求
|
||||
r($gitlabTest->apiPostTest(0, $api, $user, $options)) && p() && e('return null'); //用不存在host ID 发送一个请求
|
||||
r($gitlabTest->apiPostTest(0, $api, $user, $options)) && p() && e('return null'); //用不存在host ID 发送一个请求
|
||||
|
||||
@@ -13,29 +13,36 @@ cid=1
|
||||
- 使用空的account更新gitlab用户第account条的0属性 @禅道用户不能为空
|
||||
- 设置了密码的情况下更新gitlab用户 @二次密码不一致!
|
||||
- 通过gitlabID,用户对象正确更新用户名字 @1
|
||||
- 通过gitlabID,用户对象错误更新用户名字 @该用户已经被绑定!
|
||||
- 通过gitlabID,用户对象错误更新用户名字 @该用户已经被绑定!
|
||||
|
||||
*/
|
||||
|
||||
zenData('pipeline')->gen(5);
|
||||
zenData('oauth')->gen(5);
|
||||
|
||||
global $app;
|
||||
$app->rawModule = 'gitlab';
|
||||
$app->rawMethod = 'browse';
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
|
||||
/* Create user. */
|
||||
$user = new stdclass();
|
||||
$user->name = 'apiCreatedUser';
|
||||
$user->username = 'apiuser17';
|
||||
$user->email = 'apiuser17@test.com';
|
||||
$user->password = '12345678';
|
||||
$user->name = 'apiCreatedUser2';
|
||||
$user->username = 'apiuser19';
|
||||
$user->email = 'apiuser19@test.com';
|
||||
$user->password = '123Qwe!@#';
|
||||
$gitlab->apiCreateUser($gitlabID, $user);
|
||||
|
||||
/* Get userID. */
|
||||
$gitlabUsers = $gitlab->apiGetUsers($gitlabID);
|
||||
$userID = 0;
|
||||
foreach($gitlabUsers as $gitlabUser)
|
||||
{
|
||||
if($gitlabUser->account == 'apiuser17')
|
||||
if($gitlabUser->account == 'apiuser19')
|
||||
{
|
||||
$userID = $gitlabUser->id;
|
||||
break;
|
||||
@@ -54,3 +61,9 @@ r($gitlabTest->editUserTest($gitlabID, $user)) && p('password_repeat:0') && e('
|
||||
unset($user->password);
|
||||
$user->id = $userID;
|
||||
r($gitlabTest->editUserTest($gitlabID, $user)) && p() && e('1'); //通过gitlabID,用户对象正确更新用户名字
|
||||
|
||||
$user->id = 100000;
|
||||
r($gitlabTest->editUserTest($gitlabID, $user)) && p('account:0') && e('该用户已经被绑定!'); //通过gitlabID,用户对象错误更新用户名字
|
||||
|
||||
$user->id = -1;
|
||||
r($gitlabTest->editUserTest($gitlabID, $user)) && p('account:0') && e('该用户已经被绑定!'); //通过gitlabID,用户对象错误更新用户名字
|
||||
|
||||
@@ -10,15 +10,17 @@ title=测试gitlabModel->updateCodePath();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 更新版本库的代码地址属性path @http://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml
|
||||
- 更新版本库的代码地址属性path @https://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml
|
||||
- 使用不存在的gitlabID更新代码库的代码地址 @0
|
||||
- 使用不存在的projectID更新代码库的代码地址 @0
|
||||
- 更新版本库的代码地址 @http://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml
|
||||
- 更新版本库的代码地址 @http://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml
|
||||
|
||||
*/
|
||||
|
||||
$repo = zenData('repo')->loadYaml('repo');
|
||||
$repo->path->range('');
|
||||
$repo->gen(4);
|
||||
$repo->gen(5);
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
@@ -29,7 +31,11 @@ $repoID = 1;
|
||||
$result1 = $gitlab->updateCodePathTest($gitlabID, $projectID, $repoID);
|
||||
$result2 = $gitlab->updateCodePathTest(0, $projectID, $repoID);
|
||||
$result3 = $gitlab->updateCodePathTest($gitlabID, 0, $repoID);
|
||||
$result4 = $gitlab->updateCodePathTest($gitlabID, $projectID, $repoID);
|
||||
$result5 = $gitlab->updateCodePathTest($gitlabID, $projectID, $repoID);
|
||||
|
||||
r($result1) && p('path') && e('http://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml'); // 更新版本库的代码地址
|
||||
r($result1) && p('path') && e('https://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml'); // 更新版本库的代码地址
|
||||
r($result2) && p() && e('0'); // 使用不存在的gitlabID更新代码库的代码地址
|
||||
r($result3) && p() && e('0'); // 使用不存在的projectID更新代码库的代码地址
|
||||
r($result3) && p() && e('0'); // 使用不存在的projectID更新代码库的代码地址
|
||||
r($result4) && p('path') && e('https://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml'); // 更新版本库的代码地址
|
||||
r($result5) && p('path') && e('https://gitlabdev.qc.oop.cc/gitlab-instance-76af86df/testhtml'); // 更新版本库的代码地址
|
||||
|
||||
Reference in New Issue
Block a user