* Add gitea test case.
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
class giteaTest
|
||||
{
|
||||
public $tester;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $tester;
|
||||
$this->tester = $tester;
|
||||
$this->gitea = $this->tester->loadModel('gitea');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by id.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getByID($id)
|
||||
{
|
||||
$gitea = $this->gitea->getByID($id);
|
||||
if(empty($gitea)) return 0;
|
||||
return $gitea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitea list.
|
||||
*
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getList($orderBy = 'id_desc')
|
||||
{
|
||||
$gitea = $this->gitea->getList($orderBy);
|
||||
if(empty($gitea)) return 0;
|
||||
return array_shift($gitea);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitea pairs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPairs()
|
||||
{
|
||||
$pairs = $this->gitea->getPairs();
|
||||
return key($pairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitea tasks.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTasks($id)
|
||||
{
|
||||
$tasks = $this->gitea->getTasks($id);
|
||||
if(empty($tasks)) return 0;
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitea.
|
||||
*
|
||||
* @access public
|
||||
* @return object|string
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$giteaID = $this->gitea->create();
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
return key($errors);
|
||||
}
|
||||
|
||||
return $this->gitea->getById($giteaID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a gitea.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return object|string
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$this->gitea->update($id);
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
return key($errors);
|
||||
}
|
||||
|
||||
return $this->gitea->getById($id);
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,24 @@ author: Zeng gang
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-3
|
||||
range: 1-4
|
||||
- field: type
|
||||
range: gitlab,sonarqube,jenkins
|
||||
range: gitlab,sonarqube,jenkins,gitea
|
||||
- field: name
|
||||
range: gitlab服务器,sonarqube服务器,jenkins服务器
|
||||
range: GitLab服务器,SonarQube服务器,Jenkins服务器,Gitea服务器
|
||||
- field: url
|
||||
range: [http://10.0.1.161:51080],[http://10.0.1.161:59001],[http://10.0.1.161:58080]
|
||||
range: [http://10.0.1.161:51080],[http://10.0.1.161:59001],[http://10.0.1.161:58080],[http://10.0.7.242:9020]
|
||||
- field: account
|
||||
range: [],[admin]{2}
|
||||
range: [],[admin]{2},[]
|
||||
- field: password
|
||||
range: [],[UDJzc3cwcmQ=],[]
|
||||
range: [],[UDJzc3cwcmQ=],[RWFzeXNvZnRAcWQyMDEwIQ==],[]
|
||||
- field: token
|
||||
range: x88fZokrp5hShia2jyBN,YWRtaW46UDJzc3cwcmQ=,1196c85ba525a268570df9da627e3a7b2d
|
||||
range: x88fZokrp5hShia2jyBN,YWRtaW46UDJzc3cwcmQ=,1196c85ba525a268570df9da627e3a7b2d,c6769e6761a7d719129b2421dcb3112d936e2b1f
|
||||
- field: private
|
||||
range: 08bcc98f75d7d40053dc80722bdc117b,228b25587479f2fc7570428e8bcbabdc,ec8e41481723685d9106c88be5967c41
|
||||
range: 08bcc98f75d7d40053dc80722bdc117b,228b25587479f2fc7570428e8bcbabdc,ec8e41481723685d9106c88be5967c41,ada6cb0b0e59f4fb217bd8b75c844ac8
|
||||
- field: createdBy
|
||||
range: admin
|
||||
- field: createdDate
|
||||
range: [2021-12-09 11:23:35],[2022-01-12 08:47:37],[2022-01-12 08:47:37]
|
||||
range: [2021-12-09 11:23:35],[2022-01-12 08:47:37],[2022-01-12 08:47:37],[2022-08-08 09:33:36]
|
||||
- field: deleted
|
||||
range: 0
|
||||
|
||||
@@ -109,13 +109,13 @@ $builder->weeklyreport = array('rows' => 10, 'extends' => array('weeklyreport'))
|
||||
$builder->metting = array('rows' => 10, 'extends' => array('meeting'));
|
||||
$builder->usertpl = array('rows' => 10, 'extends' => array('usertpl'));
|
||||
|
||||
$builder->pipeline = array('rows' => 3, 'extends' => array('pipeline'));
|
||||
$builder->holiday = array('rows' => 100, 'extends' => array('holiday'));
|
||||
$builder->repo = array('rows' => 1, 'extends' => array('repo'));
|
||||
$builder->job = array('rows' => 2, 'extends' => array('job'));
|
||||
$builder->mr = array('rows' => 1, 'extends' => array('mr'));
|
||||
$builder->oauth = array('rows' => 90, 'extends' => array('oauth'));
|
||||
$builder->notify = array('rows' => 10, 'extends' => array('notify'));
|
||||
$builder->pipeline = array('rows' => 4, 'extends' => array('pipeline'));
|
||||
$builder->holiday = array('rows' => 100, 'extends' => array('holiday'));
|
||||
$builder->repo = array('rows' => 1, 'extends' => array('repo'));
|
||||
$builder->job = array('rows' => 2, 'extends' => array('job'));
|
||||
$builder->mr = array('rows' => 1, 'extends' => array('mr'));
|
||||
$builder->oauth = array('rows' => 90, 'extends' => array('oauth'));
|
||||
$builder->notify = array('rows' => 10, 'extends' => array('notify'));
|
||||
|
||||
$builder->vm = array('rows' => 1, 'extends' => array('vm'));
|
||||
$builder->vmtemplate = array('rows' => 1, 'extends' => array('vmtemplate'));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/gitea.class.php';
|
||||
$db->switchDB();
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试giteaModel->create();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
Gitea名称为空 >> name
|
||||
服务器地址为空 >> url
|
||||
正确Gitea数据 >> Gitea,http://10.0.1.161:58080,1196c85ba525a268570df9da627e3a7b2d
|
||||
|
||||
*/
|
||||
|
||||
$gitea = new giteaTest();
|
||||
|
||||
$_POST = array();
|
||||
$_POST['name'] = '';
|
||||
$_POST['url'] = 'http://10.0.7.242:9020';
|
||||
$_POST['token'] = 'c6769e6761a7d719129b2421dcb3112d936e2b1f';
|
||||
|
||||
r($gitea->create()) && p() && e('name'); // Gitea名称为空
|
||||
|
||||
$_POST['name'] = 'Gitea';
|
||||
$_POST['url'] = '';
|
||||
r($gitea->create()) && p() && e('url'); // 服务器地址为空
|
||||
|
||||
$_POST['url'] = 'http://10.0.7.242:9020';
|
||||
r($gitea->create()) && p('name,url,token') && e('Gitea,http://10.0.7.242:9020,c6769e6761a7d719129b2421dcb3112d936e2b1f'); // 正确Gitea数据
|
||||
|
||||
$db->restoreDB();
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/gitea.class.php';
|
||||
$db->switchDB();
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试giteaModel->gitById();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
使用存在的ID >> 4
|
||||
使用空的ID >> 0
|
||||
使用不存在的ID >> 0
|
||||
|
||||
*/
|
||||
|
||||
$gitea = new giteaTest();
|
||||
|
||||
$giteaID = 4;
|
||||
r($gitea->getById($giteaID)) && p('id') && e('4'); // 使用存在的ID
|
||||
|
||||
$giteaID = 0;
|
||||
r($gitea->getById($giteaID)) && p() && e(0); // 使用空的ID
|
||||
|
||||
$giteaID = 111;
|
||||
r($gitea->getById($giteaID)) && p() && e(0); // 使用不存在的ID
|
||||
|
||||
$db->restoreDB();
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/gitea.class.php';
|
||||
$db->switchDB();
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试giteaModel->gitList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取Gitea列表 >> 4
|
||||
|
||||
*/
|
||||
|
||||
$gitea = new giteaTest();
|
||||
|
||||
$orderBy = 'id_desc';
|
||||
r($gitea->getList($orderBy)) && p('id') && e('4'); // 获取Gitea列表
|
||||
|
||||
$db->restoreDB();
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/gitea.class.php';
|
||||
$db->switchDB();
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试giteaModel->gitPairs();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取Gitea >> 4
|
||||
|
||||
*/
|
||||
|
||||
$gitea = new giteaTest();
|
||||
|
||||
r($gitea->getPairs()) && p() && e('4'); // 获取Gitea
|
||||
|
||||
$db->restoreDB();
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/gitea.class.php';
|
||||
$db->switchDB();
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试giteaModel->update();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
Gitea名称为空 >> name
|
||||
服务器地址为空 >> url
|
||||
正确Gitea数据 >> Changed Gitea
|
||||
|
||||
*/
|
||||
|
||||
$gitea = new giteaTest();
|
||||
|
||||
$giteaID = 3;
|
||||
|
||||
$_POST = array();
|
||||
$_POST['name'] = '';
|
||||
$_POST['url'] = 'http://10.0.7.242:9020';
|
||||
$_POST['token'] = 'c6769e6761a7d719129b2421dcb3112d936e2b1f';
|
||||
|
||||
r($gitea->update($giteaID)) && p() && e('name'); // Gitea名称为空
|
||||
|
||||
$_POST['name'] = 'Changed Gitea';
|
||||
$_POST['url'] = '';
|
||||
r($gitea->update($giteaID)) && p() && e('url'); // 服务器地址为空
|
||||
|
||||
$_POST['url'] = 'http://10.0.1.161:58080';
|
||||
r($gitea->update($giteaID)) && p('name') && e('Changed Gitea'); // 正确Gitea数据
|
||||
|
||||
$db->restoreDB();
|
||||
@@ -178,6 +178,12 @@ switch($argv[1])
|
||||
case 'user':
|
||||
ztfRun('model/user');
|
||||
break;
|
||||
case 'gitlab':
|
||||
ztfRun('model/gitlab');
|
||||
break;
|
||||
case 'gitea':
|
||||
ztfRun('model/gitea');
|
||||
break;
|
||||
|
||||
default:
|
||||
ztfExtract($argv[1]);
|
||||
|
||||
Reference in New Issue
Block a user