From af9acf9f70a27b20cf8b64f2986117c0249a7700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 14 Aug 2024 12:50:25 +0000 Subject: [PATCH] Fix tests --- CONTRIBUTING.md | 6 ++++++ .../Functions/FunctionsCustomServerTest.php | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d8ddadda6..d3a7d060b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -553,6 +553,12 @@ To run end-2-end tests for a specific service use: docker compose exec appwrite test /usr/src/code/tests/e2e/Services/[ServiceName] ``` +To run one specific test: + +```bash +docker compose exec appwrite vendor/bin/phpunit --filter [FunctionName] +``` + ## Benchmarking You can use WRK Docker image to benchmark the server performance. Benchmarking is extremely useful when you want to compare how the server behaves before and after a change has been applied. Replace [APPWRITE_HOSTNAME_OR_IP] with your Appwrite server hostname or IP. Note that localhost is not accessible from inside the WRK container. diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index f4783055fc..0df032198b 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -450,12 +450,11 @@ class FunctionsCustomServerTest extends Scope ], $this->getHeaders())); $this->assertEquals(200, $template['headers']['status-code']); - $this->assertArrayHasKey('', $template['body']); $entrypoint = null; $rootDirectory = null; $commands = null; - foreach($template['runtimes'] as $runtime) { + foreach($template['body']['runtimes'] as $runtime) { if($runtime["name"] !== $runtimeName) { continue; } @@ -474,7 +473,7 @@ class FunctionsCustomServerTest extends Scope * Remove bellow assertion and update test to crete variable, * and ensure variable works as expected in execution. */ - $this->assertEmpty($template['variables']); + $this->assertEmpty($template['body']['variables']); // Create function using settings from template. // Deployment is automatically created from template inside endpoint @@ -513,9 +512,9 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertEquals(1, $deployments['body']['total']); - $this->assertNotEmpty($deployments['body']['deployments']['$id']); + $this->assertNotEmpty($deployments['body']['deployments'][0]['$id']); - $deploymentId = $deployments['body']['deployments']['$id']; + $deploymentId = $deployments['body']['deployments'][0]['$id']; // Wait for deployment build to finish // Deployment is automatically activated @@ -552,8 +551,8 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], ], $this->getHeaders()), []); - $this->assertEquals(200, $execution['headers']['status-code']); - $this->assertIsInt($execution['body']['total']); + $this->assertEquals(200, $users['headers']['status-code']); + $this->assertIsInt($users['body']['total']); $totalusers = $users['body']['total'];