From 34fc855c8ac1ddce84ac6fee7fc3726592a52e79 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:49:16 +0530 Subject: [PATCH 1/3] Allow deployment queries on type and size --- .../Utopia/Database/Validator/Queries/Deployments.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php index 427779efa5..42aed88ef6 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Deployments.php @@ -9,7 +9,9 @@ class Deployments extends Base 'buildId', 'activate', 'entrypoint', - 'commands' + 'commands', + 'type', + 'size' ]; /** From 6f1655a4207abf76e32b5158e3e85395d018d6ad Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:20:24 +0530 Subject: [PATCH 2/3] Add tests for querying deployments with size and type --- .../Functions/FunctionsCustomServerTest.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 0b6bf985c1..7e2183a6f9 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -732,6 +732,57 @@ class FunctionsCustomServerTest extends Scope $this->assertCount(3, $function['body']['deployments']); $this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::equal('type', ['manual'])->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(3, $function['body']['total']); + + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::greaterThan('size', 10000)->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(1, $function['body']['total']); + + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::greaterThan('size', 0)->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(3, $function['body']['total']); + return $data; } From 70c0c7707a2708d2ba9c9ab8463a25f00b4e5c6f Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:27:50 +0530 Subject: [PATCH 3/3] Add tests for negative size and invalid-string --- .../Functions/FunctionsCustomServerTest.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 67a342d843..2c20d46ccb 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -749,6 +749,40 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($function['headers']['status-code'], 200); $this->assertEquals(3, $function['body']['total']); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::equal('type', ['vcs'])->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(0, $function['body']['total']); + + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::equal('type', ['invalid-string'])->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(0, $function['body']['total']); + $function = $this->client->call( Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', @@ -783,6 +817,23 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($function['headers']['status-code'], 200); $this->assertEquals(3, $function['body']['total']); + $function = $this->client->call( + Client::METHOD_GET, + '/functions/' . $data['functionId'] . '/deployments', + array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), + [ + 'queries' => [ + Query::greaterThan('size', -100)->toString(), + ], + ] + ); + + $this->assertEquals($function['headers']['status-code'], 200); + $this->assertEquals(3, $function['body']['total']); + return $data; }