mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add async exec doc test
This commit is contained in:
@@ -369,7 +369,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
|
||||
;
|
||||
|
||||
$queueForFunctions
|
||||
->setType('delayed_execution_write')
|
||||
->setType(Func::TYPE_ASYNC_WRITE)
|
||||
->setExecution($execution)
|
||||
->setProject($project)
|
||||
->trigger();
|
||||
|
||||
@@ -8,6 +8,8 @@ use Utopia\Queue\Connection;
|
||||
|
||||
class Func extends Event
|
||||
{
|
||||
public const TYPE_ASYNC_WRITE = 'async_write';
|
||||
|
||||
protected string $jwt = '';
|
||||
protected string $type = '';
|
||||
protected string $body = '';
|
||||
|
||||
@@ -74,7 +74,7 @@ class Functions extends Action
|
||||
$type = $payload['type'] ?? '';
|
||||
|
||||
// Short-term solution to offhand write operation from API contianer
|
||||
if ($type === 'delayed_execution_write') {
|
||||
if ($type === Func::TYPE_ASYNC_WRITE) {
|
||||
$execution = new Document($payload['execution'] ?? []);
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
return;
|
||||
|
||||
@@ -1675,6 +1675,17 @@ class FunctionsCustomServerTest extends Scope
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals($cookie, $response['body']);
|
||||
|
||||
// Async execution document creation
|
||||
$this->assertEventually(function () use ($functionId) {
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(200, $executions['headers']['status-code']);
|
||||
$this->assertEquals(1, count($executions['body']['executions']));
|
||||
});
|
||||
|
||||
// Await Aggregation
|
||||
sleep(System::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', 30));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user