* Add unit test for module-job to Merge184.

This commit is contained in:
chaideqing
2023-11-21 02:59:44 +00:00
parent c1ab34076a
commit 08da5e6d35
2 changed files with 55 additions and 0 deletions
+17
View File
@@ -302,4 +302,21 @@ class jobTest
return $array;
}
/**
* Test Check parameterizedBuild.
*
* @param string $url
* @param string $userPWD
* @access public
* @return bool
*/
public function checkParameterizedBuildTest(string $url, string $userPWD): bool
{
$checked = $this->objectModel->checkParameterizedBuild($url, $userPWD);
if(dao::isError()) return dao::getError();
return $checked;
}
}
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/job.class.php';
su('admin');
/**
title=测试 jobModel->checkParameterizedBuild();
cid=1
pid=1
*/
$jenkins1 = new stdclass();
$jenkins1->url = 'pms.cc.cc';
$jenkins1->account = '123456';
$jenkins1->token = 'zxd';
$jenkins1->pipeline = '12';
$jenkins2 = new stdclass();
$jenkins2->url = 'pms.cc.cc';
$jenkins2->account = '123456';
$jenkins2->password = '8bb44ffbc4b42fcbb3152cc05fd21c67';
$jenkins2->token = '';
$jenkins2->pipeline = '11';
$jenkins3 = new stdclass();
$jenkins3->url = '';
$jenkins3->account = '';
$jenkins3->password = '';
$jenkins3->token = '';
$jenkins3->pipeline = '';
$compile = new jobTest();
r($compile->checkParameterizedBuildTest('pms.cc.cc/job/12/api/json', '123456:zxd')) && p('') && e('1');
r($compile->checkParameterizedBuildTest('pms.cc.cc/job/11/api/json', '123456:8bb44ffbc4b42fcbb3152cc05fd21c67')) && p('') && e('1');
r($compile->checkParameterizedBuildTest('', '')) && p('') && e('0');