From e36c8786ea7d9525b68f6ab03a39600ec4048e65 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:50:19 +0530 Subject: [PATCH] Add test for response format --- .../Functions/FunctionsCustomServerTest.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 1e40a2a657..a931fa4a4a 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -88,6 +88,40 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(201, $variable2['headers']['status-code']); $this->assertEquals(201, $variable3['headers']['status-code']); + $response2 = $this->client->call(Client::METHOD_POST, '/functions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-response-format' => '1.5.0', + ], $this->getHeaders()), [ + 'functionId' => ID::unique(), + 'name' => 'Test', + 'runtime' => 'php-8.0', + 'entrypoint' => 'index.php', + 'events' => [ + 'buckets.*.create', + 'buckets.*.delete', + ], + 'schedule' => '0 0 1 1 *', + 'timeout' => 10, + ]); + + $this->assertEquals(201, $response2['headers']['status-code']); + $this->assertNotEmpty($response2['body']['$id']); + $this->assertEquals('Test', $response2['body']['name']); + $this->assertEquals('php-8.0', $response2['body']['runtime']); + $this->assertEquals(true, $dateValidator->isValid($response2['body']['$createdAt'])); + $this->assertEquals(true, $dateValidator->isValid($response2['body']['$updatedAt'])); + + $functionId2 = $response2['body']['$id']; + + $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId2, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], []); + + $this->assertEquals(204, $response['headers']['status-code']); + /** * Test for FAILURE */