* Adjust gitlab unit test

This commit is contained in:
zenggang
2024-01-11 09:41:47 +00:00
parent e50ff3f699
commit b3d41cc72a
2 changed files with 25 additions and 16 deletions
+21 -12
View File
@@ -412,20 +412,29 @@ class gitlabTest
return $result->data->project->repository->tree;
}
/**
* Test getFileLastCommit method.
*
* @param string $path
* @param string $branch
* @access public
* @return object|null|array
*/
public function getFileLastCommitTest(string $path, string $branch): object|array|null
public function getFileLastCommitTest(int $repoID, string $path, string $branch = 'HEAD')
{
$repo = $this->gitlab->loadModel('repo')->getByID(1);
$repo = $this->gitlab->loadModel('repo')->getByID($repoID);
$result = $this->gitlab->getFileLastCommit($repo, $path, $branch);
if(!$result) return $result;
if(isset($result->errors)) return array_column($result->errors, 'message');
return $result;
}
public function apiGetTest(int|string $host, string $api)
{
$result = $this->gitlab->apiGet($host, $api);
if(is_null($result)) return 'return null';
if(isset($result->id)) return 'success';
return $result;
}
public function apiPostTest(int|string $host, string $api, array|object $data = array(), array $options = array())
{
$result = $this->gitlab->apiGet($host, $api, $data, $options);
if(is_null($result)) return 'return null';
if(isset($result->name)) return 'success';
return $result;
}
}