tests(functions): after paginatio tests
This commit is contained in:
parent
8296021b63
commit
2a540ff799
|
@ -45,7 +45,7 @@
|
|||
"utopia-php/cache": "0.4.*",
|
||||
"utopia-php/cli": "0.11.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "0.6.*",
|
||||
"utopia-php/database": "dev-fix-after-pagination-with-order as 0.6.1",
|
||||
"utopia-php/locale": "0.4.*",
|
||||
"utopia-php/registry": "0.5.*",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
|
|
29
composer.lock
generated
29
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c2bda60e7b774a0c813f52033a268c6c",
|
||||
"content-hash": "e79cbd92bfd81499b5111bf3329e2318",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
@ -1984,16 +1984,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.6.1",
|
||||
"version": "dev-fix-after-pagination-with-order",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "59d9d34164b6fb896bc43085a9a82a292b43473a"
|
||||
"reference": "2179adfdeb385864cebc86e2b063929dcfbf77e6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/59d9d34164b6fb896bc43085a9a82a292b43473a",
|
||||
"reference": "59d9d34164b6fb896bc43085a9a82a292b43473a",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/2179adfdeb385864cebc86e2b063929dcfbf77e6",
|
||||
"reference": "2179adfdeb385864cebc86e2b063929dcfbf77e6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2041,9 +2041,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.6.1"
|
||||
"source": "https://github.com/utopia-php/database/tree/fix-after-pagination-with-order"
|
||||
},
|
||||
"time": "2021-08-05T17:19:16+00:00"
|
||||
"time": "2021-08-09T12:01:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
@ -6254,9 +6254,18 @@
|
|||
"time": "2015-12-17T08:42:14+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/database",
|
||||
"version": "dev-fix-after-pagination-with-order",
|
||||
"alias": "0.6.1",
|
||||
"alias_normalized": "0.6.1.0"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"utopia-php/database": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
@ -6278,5 +6287,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.0"
|
||||
},
|
||||
"plugin-api-version": "2.1.0"
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class FunctionsCustomClientTest extends Scope
|
|||
]);
|
||||
|
||||
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||
|
||||
|
||||
$execution = $this->client->call(Client::METHOD_POST, '/functions/'.$function['body']['$id'].'/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
|
@ -121,7 +121,7 @@ class FunctionsCustomClientTest extends Scope
|
|||
]);
|
||||
|
||||
$this->assertEquals(401, $execution['headers']['status-code']);
|
||||
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class FunctionsCustomClientTest extends Scope
|
|||
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||
|
||||
$executionId = $execution['body']['$id'] ?? '';
|
||||
|
||||
|
||||
sleep(10);
|
||||
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions/'.$executionId, [
|
||||
|
@ -212,19 +212,52 @@ class FunctionsCustomClientTest extends Scope
|
|||
$this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']);
|
||||
$this->assertNotEmpty($output['APPWRITE_FUNCTION_JWT']);
|
||||
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions', [
|
||||
return [
|
||||
'functionId' => $functionId
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreateCustomExecution
|
||||
*/
|
||||
public function testListExecutions(array $data)
|
||||
{
|
||||
$functionId = $data['functionId'];
|
||||
$projectId = $this->getProject()['$id'];
|
||||
$apikey = $this->getProject()['apiKey'];
|
||||
|
||||
$execution = $this->client->call(Client::METHOD_POST, '/functions/'.$functionId.'/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), [
|
||||
'data' => 'foobar',
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $execution['headers']['status-code']);
|
||||
|
||||
sleep(10);
|
||||
|
||||
$base = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apikey,
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $executions['headers']['status-code']);
|
||||
$this->assertCount(1, $executions['body']['executions']);
|
||||
$this->assertEquals('completed', $executions['body']['executions'][0]['status']);
|
||||
$this->assertStringContainsString('foobar', $executions['body']['executions'][0]['stdout']);
|
||||
$this->assertStringContainsString($this->getUser()['$id'], $executions['body']['executions'][0]['stdout']);
|
||||
|
||||
return [];
|
||||
}
|
||||
$this->assertEquals(200, $base['headers']['status-code']);
|
||||
$this->assertCount(2, $base['body']['executions']);
|
||||
$this->assertEquals('completed', $base['body']['executions'][0]['status']);
|
||||
$this->assertEquals('completed', $base['body']['executions'][1]['status']);
|
||||
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/'.$functionId.'/executions', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $projectId,
|
||||
'x-appwrite-key' => $apikey,
|
||||
], [
|
||||
'after' => $base['body']['executions'][0]['$id']
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $executions['body']['executions']);
|
||||
$this->assertEquals($base['body']['executions'][1]['$id'], $executions['body']['executions'][0]['$id']);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,16 +77,51 @@ class FunctionsCustomServerTest extends Scope
|
|||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions', array_merge([
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'functionId' => 'unique()',
|
||||
'name' => 'Test 2',
|
||||
'runtime' => 'php-8.0',
|
||||
'vars' => [
|
||||
'funcKey1' => 'funcValue1',
|
||||
'funcKey2' => 'funcValue2',
|
||||
'funcKey3' => 'funcValue3',
|
||||
],
|
||||
'events' => [
|
||||
'account.create',
|
||||
'account.delete',
|
||||
],
|
||||
'schedule' => '0 0 1 1 *',
|
||||
'timeout' => 10,
|
||||
]);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
|
||||
$functions = $this->client->call(Client::METHOD_GET, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals($function['headers']['status-code'], 200);
|
||||
$this->assertEquals($function['body']['sum'], 1);
|
||||
$this->assertIsArray($function['body']['functions']);
|
||||
$this->assertCount(1, $function['body']['functions']);
|
||||
$this->assertEquals($function['body']['functions'][0]['name'], 'Test');
|
||||
$this->assertEquals($functions['headers']['status-code'], 200);
|
||||
$this->assertEquals($functions['body']['sum'], 2);
|
||||
$this->assertIsArray($functions['body']['functions']);
|
||||
$this->assertCount(2, $functions['body']['functions']);
|
||||
$this->assertEquals($functions['body']['functions'][0]['name'], 'Test');
|
||||
$this->assertEquals($functions['body']['functions'][1]['name'], 'Test 2');
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/functions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'after' => $functions['body']['functions'][0]['$id']
|
||||
]);
|
||||
|
||||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertCount(1, $response['body']['functions']);
|
||||
$this->assertEquals($response['body']['functions'][0]['name'], 'Test 2');
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue