* Add unit case.
This commit is contained in:
+68
-7
@@ -22,12 +22,23 @@ class ciTest
|
||||
return $lang->devops->menu->code;
|
||||
}
|
||||
|
||||
public function getCompileByID($compileID)
|
||||
{
|
||||
global $tester;
|
||||
return $tester->dao->select('compile.*, job.engine,job.pipeline, pipeline.name as jenkinsName,job.server,pipeline.url,pipeline.account,pipeline.token,pipeline.password')
|
||||
->from(TABLE_COMPILE)->alias('compile')
|
||||
->leftJoin(TABLE_JOB)->alias('job')->on('compile.job=job.id')
|
||||
->leftJoin(TABLE_PIPELINE)->alias('pipeline')->on('job.server=pipeline.id')
|
||||
->where('compile.id')->eq($compileID)
|
||||
->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync compile status.
|
||||
*
|
||||
* @param int $jobID
|
||||
* @access public
|
||||
* @return string
|
||||
* @return string|object
|
||||
*/
|
||||
public function syncCompileStatusTest($jobID)
|
||||
{
|
||||
@@ -41,12 +52,7 @@ class ciTest
|
||||
->andWhere('compileStatus')->eq('created')
|
||||
->fetchPairs();
|
||||
|
||||
$compile = $tester->dao->select('compile.*, job.engine,job.pipeline, pipeline.name as jenkinsName,job.server,pipeline.url,pipeline.account,pipeline.token,pipeline.password')
|
||||
->from(TABLE_COMPILE)->alias('compile')
|
||||
->leftJoin(TABLE_JOB)->alias('job')->on('compile.job=job.id')
|
||||
->leftJoin(TABLE_PIPELINE)->alias('pipeline')->on('job.server=pipeline.id')
|
||||
->where('compile.id')->eq($compileID)
|
||||
->fetch();
|
||||
$compile = $this->getCompileByID($compileID);
|
||||
|
||||
$this->objectModel->syncCompileStatus($compile, $notCompileMR);
|
||||
$compile = $tester->loadModel('compile')->getByID($compileID);
|
||||
@@ -54,4 +60,59 @@ class ciTest
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $compile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync gitlab task status.
|
||||
*
|
||||
* @param int $jobID
|
||||
* @access public
|
||||
* @return string|bool
|
||||
*/
|
||||
public function syncGitlabTaskStatusTest($jobID)
|
||||
{
|
||||
global $tester;
|
||||
$tester->loadModel('job')->exec($jobID);
|
||||
$compileID = $tester->dao->select('id')->from(TABLE_COMPILE)->orderBy('id_desc')->fetch('id');
|
||||
$compile = $this->getCompileByID($compileID);
|
||||
|
||||
$this->objectModel->syncGitlabTaskStatus($compile);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update build status.
|
||||
*
|
||||
* @param int $compileID
|
||||
* @param string $status
|
||||
* @access public
|
||||
* @return string|object
|
||||
*/
|
||||
public function updateBuildStatusTest($compileID, $status)
|
||||
{
|
||||
$compile = $this->getCompileByID($compileID);
|
||||
$this->objectModel->updateBuildStatus($compile, $status);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
global $tester;
|
||||
$compile = $tester->loadModel('compile')->getByID($compileID);
|
||||
return $compile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send request.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $data
|
||||
* @param string $userPWD
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function sendRequestTest($url, $data, $userPWD)
|
||||
{
|
||||
$return = $this->objectModel->sendRequest($url, $data, $userPWD);
|
||||
return $return ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user