From 7c35464f73fc3957e61a9ed99c7e2534d1c895f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 19 Aug 2024 09:00:56 +0000 Subject: [PATCH] Fix tests --- .../Functions/FunctionsCustomServerTest.php | 16 ++++++++-------- tests/resources/functions/php-scopes/index.php | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 8bf1454362..e6908efc43 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -2064,8 +2064,9 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(201, $execution['headers']['status-code']); $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); - $this->assertNotEmpty($execution['body']['responseBody']); $this->assertGreaterThan(0, $execution['body']['duration']); + $this->assertNotEmpty($execution['body']['responseBody']); + $this->assertStringContainsString("total", $execution['body']['responseBody']); $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ 'content-type' => 'application/json', @@ -2074,23 +2075,22 @@ class FunctionsCustomServerTest extends Scope 'async' => true ]); - $this->assertEquals(201, $execution['headers']['status-code']); - $this->assertNotEmpty(201, $execution['body']['$id']); + $this->assertEquals(202, $execution['headers']['status-code']); + $this->assertNotEmpty($execution['body']['$id']); \sleep(10); $execution = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $execution['body']['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'async' => true - ]); + ], $this->getHeaders()), []); - $this->assertEquals(201, $execution['headers']['status-code']); + $this->assertEquals(200, $execution['headers']['status-code']); $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); - $this->assertNotEmpty($execution['body']['responseBody']); $this->assertGreaterThan(0, $execution['body']['duration']); + $this->assertNotEmpty($execution['body']['logs']); + $this->assertStringContainsString("total", $execution['body']['logs']); // Cleanup : Delete function $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [ diff --git a/tests/resources/functions/php-scopes/index.php b/tests/resources/functions/php-scopes/index.php index e05653b709..905d924eb7 100644 --- a/tests/resources/functions/php-scopes/index.php +++ b/tests/resources/functions/php-scopes/index.php @@ -12,5 +12,7 @@ return function ($context) { ->setProject(getenv('APPWRITE_FUNCTION_PROJECT_ID')) ->setKey($context->req->headers['x-appwrite-key']); $users = new Users($client); - return $context->res->json($users->list()); + $response = $users->list(); + $context->log($response); + return $context->res->json($response); };