mirror of
https://github.com/appwrite/appwrite
synced 2026-05-05 22:38:37 +00:00
Merge pull request #10357 from appwrite/feat-execution-deployment-id
Feat: execution.deploymentId response model
This commit is contained in:
commit
7e81f09747
3 changed files with 53 additions and 2 deletions
|
|
@ -38,12 +38,19 @@ class Execution extends Model
|
|||
'example' => [Role::any()->toString()],
|
||||
'array' => true,
|
||||
])
|
||||
// TODO: Sites listLogs will not have this, and will need siteId instead
|
||||
->addRule('functionId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Function ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea6g16897e',
|
||||
])
|
||||
->addRule('deploymentId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Function\'s deployment ID used to create the execution.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('trigger', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.',
|
||||
|
|
|
|||
|
|
@ -945,6 +945,29 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals(1, $executions['body']['total']);
|
||||
$this->assertIsArray($executions['body']['executions']);
|
||||
$this->assertCount(1, $executions['body']['executions']);
|
||||
$this->assertEquals($data['deploymentId'], $executions['body']['executions'][0]['deploymentId']);
|
||||
|
||||
$executions = $this->listExecutions($data['functionId'], [
|
||||
'queries' => [
|
||||
Query::equal('deploymentId', [$data['deploymentId']])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $executions['headers']['status-code']);
|
||||
$this->assertEquals(1, $executions['body']['total']);
|
||||
$this->assertIsArray($executions['body']['executions']);
|
||||
$this->assertCount(1, $executions['body']['executions']);
|
||||
|
||||
$executions = $this->listExecutions($data['functionId'], [
|
||||
'queries' => [
|
||||
Query::equal('deploymentId', ['some-random-id'])->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $executions['headers']['status-code']);
|
||||
$this->assertEquals(0, $executions['body']['total']);
|
||||
$this->assertIsArray($executions['body']['executions']);
|
||||
$this->assertCount(0, $executions['body']['executions']);
|
||||
|
||||
$executions = $this->listExecutions($data['functionId'], [
|
||||
'queries' => [
|
||||
|
|
@ -1034,8 +1057,9 @@ class FunctionsCustomServerTest extends Scope
|
|||
*/
|
||||
$execution = $this->getExecution($data['functionId'], $data['executionId']);
|
||||
|
||||
$this->assertEquals($execution['headers']['status-code'], 200);
|
||||
$this->assertEquals($execution['body']['$id'], $data['executionId']);
|
||||
$this->assertEquals(200, $execution['headers']['status-code']);
|
||||
$this->assertEquals($data['executionId'], $execution['body']['$id']);
|
||||
$this->assertEquals($data['deploymentId'], $execution['body']['deploymentId']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
|
|
|||
|
|
@ -1887,6 +1887,7 @@ class SitesCustomServerTest extends Scope
|
|||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString($deploymentId, $logs['body']['executions'][0]['deploymentId']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-inline", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
|
|
@ -1896,6 +1897,24 @@ class SitesCustomServerTest extends Scope
|
|||
$log1Id = $logs['body']['executions'][0]['$id'];
|
||||
$this->assertNotEmpty($log1Id);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
Query::equal('deploymentId', [$deploymentId])->toString()
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertGreaterThanOrEqual(1, $logs['body']['total']);
|
||||
$this->assertCount(1, $logs['body']['executions']);
|
||||
|
||||
$logs = $this->listLogs($siteId, [
|
||||
Query::orderDesc('$createdAt')->toString(),
|
||||
Query::limit(1)->toString(),
|
||||
Query::equal('deploymentId', ['some-random-id'])->toString()
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertEquals(0, $logs['body']['total']);
|
||||
$this->assertCount(0, $logs['body']['executions']);
|
||||
|
||||
$response = $proxyClient->call(Client::METHOD_GET, '/logs-action');
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString("Action logs printed.", $response['body']);
|
||||
|
|
@ -1905,6 +1924,7 @@ class SitesCustomServerTest extends Scope
|
|||
Query::limit(1)->toString(),
|
||||
]);
|
||||
$this->assertEquals(200, $logs['headers']['status-code']);
|
||||
$this->assertStringContainsString($deploymentId, $logs['body']['executions'][0]['deploymentId']);
|
||||
$this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']);
|
||||
$this->assertStringContainsString("/logs-action", $logs['body']['executions'][0]['requestPath']);
|
||||
$this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue