+ Add unit test case for mr->apiDeleteMR.

This commit is contained in:
caoyanyi
2023-12-19 16:07:57 +08:00
parent 6c619422a9
commit 99fa080b9c
3 changed files with 71 additions and 7 deletions
+7 -7
View File
@@ -708,19 +708,19 @@ class mrModel extends model
public function apiDeleteMR(int $hostID, string $projectID, int $MRID): object|null
{
$host = $this->loadModel('pipeline')->getByID($hostID);
if(!$host) return null;
if($host->type == 'gitlab')
{
$url = sprintf($this->loadModel('gitlab')->getApiRoot($hostID), "/projects/$projectID/merge_requests/$MRID");
return json_decode(commonModel::http($url, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
}
else
$rowMR = $this->apiGetSingleMR($hostID, $projectID, $MRID);
if($rowMR->state == 'opened')
{
$rowMR = $this->apiGetSingleMR($hostID, $projectID, $MRID);
if($rowMR->state == 'opened')
{
$url = sprintf($this->loadModel($host->type)->getApiRoot($hostID), "/repos/$projectID/pulls/$MRID");
return json_decode(commonModel::http($url, array('state' => 'closed'), array(), array(), 'json', 'PATCH'));
}
$url = sprintf($this->loadModel($host->type)->getApiRoot($hostID), "/repos/$projectID/pulls/$MRID");
return json_decode(commonModel::http($url, array('state' => 'closed'), array(), array(), 'json', 'PATCH'));
}
return null;