* Add repo unit test.
This commit is contained in:
@@ -2309,6 +2309,8 @@ class repoModel extends model
|
||||
public function updateCommitDate(int $repoID): void
|
||||
{
|
||||
$repo = $this->getByID($repoID);
|
||||
if(empty($repo->id)) return;
|
||||
|
||||
if($repo->SCM == 'Gitlab')
|
||||
{
|
||||
$scm = $this->app->loadClass('scm');
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/repo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 repoModel->getListByCondition();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 根据query查询 @0
|
||||
- query为空时查询第1条的name属性 @testHtml
|
||||
- 排序条件查询属性id @1
|
||||
- 按分页查询属性id @3
|
||||
|
||||
*/
|
||||
|
||||
zdTable('repo')->config('repo')->gen(5);
|
||||
|
||||
$repo = $tester->loadModel('repo');
|
||||
$repo->app->moduleName = 'repo';
|
||||
$repo->app->methodName = 'browse';
|
||||
|
||||
$repoQuery = "path like '%123%'";
|
||||
$orderBy = 'id_asc';
|
||||
|
||||
$pager = new stdclass();
|
||||
$pager->recPerPage = 2;
|
||||
$pager->pageID = 2;
|
||||
$repo->app->loadClass('pager', true);
|
||||
$pager = pager::init(0, $pager->recPerPage, $pager->pageID);
|
||||
|
||||
r($repo->getListByCondition($repoQuery, $SCM = 'Gitlab')) && p() && e('0'); //根据query查询
|
||||
r($repo->getListByCondition('', $SCM = 'Gitlab')) && p('1:name') && e('testHtml'); //query为空时查询
|
||||
|
||||
$result = $repo->getListByCondition('', $SCM = 'Gitlab', $orderBy);
|
||||
r(array_shift($result)) && p('id') && e(1); //排序条件查询
|
||||
|
||||
$result = $repo->getListByCondition('', $SCM = 'Gitlab,Gitea', $orderBy, $pager);
|
||||
r(array_shift($result)) && p('id') && e(3); //按分页查询
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/repo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 repoModel->updateCommitDate();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 更新gitlab版本库属性lastCommit @2023-12-23 11:39:02
|
||||
- 更新gitea版本库属性lastCommit @~~
|
||||
- 更新空版本库 @return empty
|
||||
|
||||
*/
|
||||
|
||||
zdTable('repo')->config('repo')->gen(5);
|
||||
|
||||
$repo = new repoTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
$giteaID = 3;
|
||||
|
||||
r($repo->updateCommitDateTest($gitlabID)) && p('lastCommit') && e('2023-12-23 11:39:02'); //更新gitlab版本库
|
||||
r($repo->updateCommitDateTest($giteaID)) && p('lastCommit') && e('~~'); //更新gitea版本库
|
||||
r($repo->updateCommitDateTest(0)) && p() && e('return empty'); //更新空版本库
|
||||
@@ -344,6 +344,16 @@ class repoTest
|
||||
return $this->objectModel->getByID($repoID);
|
||||
}
|
||||
|
||||
public function updateCommitDateTest(int $repoID)
|
||||
{
|
||||
$this->objectModel->updateCommitDate($repoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$repo = $this->objectModel->getByID($repoID);
|
||||
return !empty($repo->id) ? $repo : 'return empty';
|
||||
}
|
||||
|
||||
public function getUnsyncedCommitsTest(int $repoID)
|
||||
{
|
||||
global $dao;
|
||||
|
||||
Reference in New Issue
Block a user