1
0
Fork 0
mirror of synced 2024-09-28 15:31:43 +12:00

Merge pull request #8622 from appwrite/fix-function-template-async-test

Fix: Add Functions templates async test
This commit is contained in:
Christy Jacob 2024-09-05 21:04:20 +04:00 committed by GitHub
commit 60b3b3a061
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -568,6 +568,36 @@ class FunctionsCustomServerTest extends Scope
$this->assertStringContainsString("Total users: " . $totalusers, $execution['body']['logs']);
// Execute function again but async
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'path' => '/ping',
'async' => true
]);
$this->assertEquals(202, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertEquals('waiting', $execution['body']['status']);
$executionId = $execution['body']['$id'];
// Wait for async execuntion to finish
sleep(5);
// Ensure execution was successful
$execution = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $executionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $execution['headers']['status-code']);
$this->assertEquals("completed", $execution['body']['status']);
$this->assertEquals(200, $execution['body']['responseStatusCode']);
$this->assertEmpty($execution['body']['responseBody']);
$this->assertEmpty($execution['body']['errors']);
$this->assertStringContainsString("Total users: " . $totalusers, $execution['body']['logs']);
// Cleanup : Delete function
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
'content-type' => 'application/json',