Add repo unittest.

This commit is contained in:
denghongtao
2022-10-10 01:36:40 +00:00
parent a64b760da6
commit 98bb2938b7
3 changed files with 38 additions and 6 deletions
+18 -4
View File
@@ -43,20 +43,34 @@ class repoTest
public function getListTest($projectID = 0, $SCM = '', $orderBy = 'id_desc', $pager = null)
{
$objects = $this->objectModel->getList($projectID, $SCM, $orderBy, $pager);
$objects = $this->objectModel->getList($projectID , $SCM, $orderBy , $pager );
if(dao::isError()) return dao::getError();
return $objects;
if(!empty($objects))
{
return $objects[1]->name;
}
else
{
return 'empty';
}
}
public function getListBySCMTest($scm, $type = 'all')
{
$objects = $this->objectModel->getListBySCM($scm, $type);
$objects = $this->objectModel->getListBySCM($scm, $type = 'all');
if(dao::isError()) return dao::getError();
return $objects;
if(!empty($objects))
{
return $objects[0]->name;
}
else
{
return 'empty';
}
}
public function createTest()
+14 -1
View File
@@ -13,5 +13,18 @@ pid=1
*/
$repo = new repoTest();
$result1 = $repo->getCloneUrlTest(1);
$result2 = $repo->getCloneUrlTest(2);
$result3 = $repo->getCloneUrlTest(3);
$result4 = $repo->getCloneUrlTest(4);
$result5 = $repo->getCloneUrlTest(7);
$result6 = $repo->getCloneUrlTest(11);
$result7 = $repo->getCloneUrlTest(0);
r($repo->getCloneUrlTest()) && p() && e();
r($result1) && p('http') && e('');
r($result2) && p('http') && e('');
r($result3) && p('http') && e('');
r($result4) && p('http') && e('');
r($result5) && p('http') && e('');
r($result6) && p('http') && e('');
r($result7) && p('http') && e('');
+6 -1
View File
@@ -13,5 +13,10 @@ pid=1
*/
$repo = new repoTest();
$result1 = $repo->getListBySCMTest('Gitlab');
$result2 = $repo->getListBySCMTest('gogs');
$result3 = $repo->getListBySCMTest('empty');
r($repo->getListBySCMTest()) && p() && e();
r($result1) && p('') && e('723test');
r($result2) && p('') && e('empty');
r($result3) && p('') && e('empty');