* Add gitlab unit test.
This commit is contained in:
@@ -349,4 +349,22 @@ class gitlabTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function createGroupTest(int $gitlabID, object $project)
|
||||
{
|
||||
$result = $this->gitlab->createGroup($gitlabID, $project);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function editGroupTest(int $gitlabID, object $project)
|
||||
{
|
||||
$result = $this->gitlab->editGroup($gitlabID, $project);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::createGroup();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 使用空的名字创建gitlab群组第name条的0属性 @群组名称不能为空
|
||||
- 使用空的群组URL创建gitlab群组第path条的0属性 @群组URL不能为空
|
||||
- 通过gitlabID,projectID,分支对象正确创建GitLab分支 @1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('pipeline')->gen(5);
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
$group = new stdclass();
|
||||
$group->name = '';
|
||||
$group->path = 'unit_test_group17';
|
||||
$group->description = 'unit_test_group desc';
|
||||
$group->visibility = 'public';
|
||||
$group->request_access_enabled = '1';
|
||||
$group->lfs_enabled = '1';
|
||||
$group->project_creation_level = 'developer';
|
||||
$group->subgroup_creation_level = 'maintainer';
|
||||
|
||||
r($gitlab->createGroupTest($gitlabID, $group)) && p('name:0') && e('群组名称不能为空'); //使用空的名字创建gitlab群组
|
||||
|
||||
$group->name = 'unitTestGroup17';
|
||||
$group->path = '';
|
||||
r($gitlab->createGroupTest($gitlabID, $group)) && p('path:0') && e('群组URL不能为空'); //使用空的群组URL创建gitlab群组
|
||||
|
||||
$group->path = 'unit_test_group17';
|
||||
$result = $gitlab->createGroupTest($gitlabID, $group);
|
||||
if(!empty($result[0]) and $result[0] == '保存失败,群组URL路径已经被使用。') $result = true;
|
||||
r($result) && p() && e('1'); //通过gitlabID,projectID,分支对象正确创建GitLab分支
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 gitlabModel::editGroup();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 使用空的groupID创建gitlab群组第name条的0属性 @群组名称不能为空
|
||||
- 通过gitlabID,用户对象正确更新用户名字 @1
|
||||
|
||||
*/
|
||||
|
||||
zdTable('pipeline')->gen(5);
|
||||
|
||||
$gitlab = $tester->loadModel('gitlab');
|
||||
|
||||
$gitlabID = 1;
|
||||
|
||||
/* Create group. */
|
||||
$group = new stdclass();
|
||||
$group->name = 'unitTestGroup17';
|
||||
$group->path = 'unit_test_group17';
|
||||
$group->description = 'unit_test_group desc';
|
||||
$group->visibility = 'public';
|
||||
$group->request_access_enabled = '1';
|
||||
$group->lfs_enabled = '1';
|
||||
$group->project_creation_level = 'developer';
|
||||
$group->subgroup_creation_level = 'maintainer';
|
||||
$gitlab->apiCreateGroup($gitlabID, $group);
|
||||
|
||||
/* Get groupID. */
|
||||
$gitlabGroups = $gitlab->apiGetGroups($gitlabID);
|
||||
foreach($gitlabGroups as $gitlabGroup)
|
||||
{
|
||||
if($gitlabGroup->name == 'unitTestGroup17')
|
||||
{
|
||||
$groupID = $gitlabGroup->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$group = new stdclass();
|
||||
$group->description = 'apiUpdatedGroup';
|
||||
|
||||
$gitlabTest = new gitlabTest();
|
||||
r($gitlabTest->editGroupTest($gitlabID, $group)) && p('name:0') && e('群组名称不能为空'); //使用空的groupID创建gitlab群组
|
||||
|
||||
$group->id = $groupID;
|
||||
$group->name = 'unitTestGroup17';
|
||||
r($gitlabTest->editGroupTest($gitlabID, $group)) && p() && e('1'); //通过gitlabID,用户对象正确更新用户名字
|
||||
Reference in New Issue
Block a user