1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00

VCS tests

This commit is contained in:
Khushboo Verma 2023-10-13 18:50:58 +05:30
parent 615bd5148e
commit 66ec7f2e1d
6 changed files with 49 additions and 63 deletions

View file

@ -35,6 +35,7 @@ use Utopia\Detector\Adapter\Ruby;
use Utopia\Detector\Adapter\Swift;
use Utopia\Detector\Detector;
use Utopia\Validator\Boolean;
use Utopia\VCS\Exception\RepositoryNotFound;
use function Swoole\Coroutine\batch;
@ -458,9 +459,9 @@ App::post('/v1/vcs/github/installations/:installationId/providerRepositories/:pr
$github->initializeVariables($providerInstallationId, $privateKey, $githubAppId);
$owner = $github->getOwnerName($providerInstallationId);
$repositoryName = $github->getRepositoryName($providerRepositoryId);
if (empty($repositoryName)) {
try {
$repositoryName = $github->getRepositoryName($providerRepositoryId);
} catch (RepositoryNotFound $e) {
throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND);
}
@ -720,9 +721,9 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro
$github->initializeVariables($providerInstallationId, $privateKey, $githubAppId);
$owner = $github->getOwnerName($providerInstallationId) ?? '';
$repositoryName = $github->getRepositoryName($providerRepositoryId) ?? '';
if (empty($repositoryName)) {
try {
$repositoryName = $github->getRepositoryName($providerRepositoryId) ?? '';
} catch (RepositoryNotFound $e) {
throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND);
}
@ -766,9 +767,9 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pro
$github->initializeVariables($providerInstallationId, $privateKey, $githubAppId);
$owner = $github->getOwnerName($providerInstallationId) ?? '';
$repositoryName = $github->getRepositoryName($providerRepositoryId) ?? '';
if (empty($repositoryName)) {
try {
$repositoryName = $github->getRepositoryName($providerRepositoryId) ?? '';
} catch (RepositoryNotFound $e) {
throw new Exception(Exception::PROVIDER_REPOSITORY_NOT_FOUND);
}

View file

@ -649,7 +649,7 @@ App::patch('/v1/mock/functions-v2')
$response->noContent();
});
App::get('/v1/mock/github/callback')
App::get('/v1/mock/github/callback')
->desc('Create installation document using GitHub installation id')
->groups(['mock', 'api', 'vcs'])
->label('scope', 'public')

View file

@ -66,7 +66,7 @@
"utopia-php/registry": "0.5.*",
"utopia-php/storage": "0.17.*",
"utopia-php/swoole": "0.5.*",
"utopia-php/vcs": "0.5.*",
"utopia-php/vcs": "0.6.*",
"utopia-php/websocket": "0.1.*",
"resque/php-resque": "1.3.6",
"matomo/device-detector": "6.1.*",

26
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "13a3bdc7c1dec5756bf58ec73a49753d",
"content-hash": "9fef5fb0274738d369f80b48741a2524",
"packages": [
{
"name": "adhocore/jwt",
@ -2152,16 +2152,16 @@
},
{
"name": "utopia-php/database",
"version": "0.43.4",
"version": "0.43.5",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "cabdd02e8dc1732eb0b22007c511e7bb3caa5c8c"
"reference": "5f7b05189cfbcc0506090498c580c5765375a00a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/cabdd02e8dc1732eb0b22007c511e7bb3caa5c8c",
"reference": "cabdd02e8dc1732eb0b22007c511e7bb3caa5c8c",
"url": "https://api.github.com/repos/utopia-php/database/zipball/5f7b05189cfbcc0506090498c580c5765375a00a",
"reference": "5f7b05189cfbcc0506090498c580c5765375a00a",
"shasum": ""
},
"require": {
@ -2202,9 +2202,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.43.4"
"source": "https://github.com/utopia-php/database/tree/0.43.5"
},
"time": "2023-09-28T09:00:05+00:00"
"time": "2023-10-06T06:49:47+00:00"
},
{
"name": "utopia-php/domains",
@ -3151,16 +3151,16 @@
},
{
"name": "utopia-php/vcs",
"version": "0.5.0",
"version": "0.6.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/vcs.git",
"reference": "47144f272030b7ed1b05471f2cb3aabeb8cb831c"
"reference": "be866170c42912f0d371421346a69f4f575eb116"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/47144f272030b7ed1b05471f2cb3aabeb8cb831c",
"reference": "47144f272030b7ed1b05471f2cb3aabeb8cb831c",
"url": "https://api.github.com/repos/utopia-php/vcs/zipball/be866170c42912f0d371421346a69f4f575eb116",
"reference": "be866170c42912f0d371421346a69f4f575eb116",
"shasum": ""
},
"require": {
@ -3194,9 +3194,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/vcs/issues",
"source": "https://github.com/utopia-php/vcs/tree/0.5.0"
"source": "https://github.com/utopia-php/vcs/tree/0.6.0"
},
"time": "2023-09-13T19:05:52+00:00"
"time": "2023-10-13T13:07:13+00:00"
},
{
"name": "utopia-php/websocket",

View file

@ -4,5 +4,4 @@ namespace Tests\E2E\Services\VCS;
trait VCSBase
{
}

View file

@ -84,27 +84,15 @@ class VCSConsoleClientTest extends Scope
* Test for FAILURE
*/
// $runtime = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId/detection', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [
// 'installationId' => $installationId,
// 'providerRepositoryId' => 'randomRepositoryId'
// ]);
$runtime = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId/detection', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'installationId' => $installationId,
'providerRepositoryId' => 'randomRepositoryId'
]);
// $this->assertEquals(404, $runtime['headers']['status-code']);
// TODO: throw 404 from GitHub.php if repo not found
// $runtime = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId .'/detection', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [
// 'installationId' => $installationId,
// 'providerRepositoryId' => $this->providerRepositoryId,
// 'providerRootDirectory' => ''̦
// ]);
// $this->assertEquals(404, $runtime['headers']['status-code']);
$this->assertEquals(404, $runtime['headers']['status-code']);
}
/**
@ -186,16 +174,15 @@ class VCSConsoleClientTest extends Scope
* Test for FAILURE
*/
// $repository = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [
// 'installationId' => $installationId,
// 'providerRepositoryId' => 'randomRepositoryId'
// ]);
$repository = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'installationId' => $installationId,
'providerRepositoryId' => 'randomRepositoryId'
]);
// $this->assertEquals(404, $repository['headers']['status-code']);
// TODO: Throw 404 if repository not found
$this->assertEquals(404, $repository['headers']['status-code']);
}
/**
@ -224,16 +211,15 @@ class VCSConsoleClientTest extends Scope
* Test for FAILURE
*/
// $repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId/branches', array_merge([
// 'content-type' => 'application/json',
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], $this->getHeaders()), [
// 'installationId' => $installationId,
// 'providerRepositoryId' => 'randomRepositoryId'
// ]);
$repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/randomRepositoryId/branches', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'installationId' => $installationId,
'providerRepositoryId' => 'randomRepositoryId'
]);
// $this->assertEquals(404, $repositoryBranches['headers']['status-code']);
// TODO: Throw error from listBranches
$this->assertEquals(404, $repositoryBranches['headers']['status-code']);
}
/**