Add test for request filters

This commit is contained in:
Khushboo Verma
2024-09-25 23:36:00 +05:30
parent 5f97aafe46
commit fdf73f8a7a
@@ -2719,6 +2719,55 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']);
}
public function testRequestFilters()
{
// create function
$response = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => ID::unique(),
'name' => 'Test',
'runtime' => 'php-8.0',
'entrypoint' => 'index.php',
'timeout' => 15,
]);
$this->assertEquals(201, $response['headers']['status-code']);
// create another function
$response = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'functionId' => ID::unique(),
'name' => 'Test2',
'runtime' => 'php-8.0',
'entrypoint' => 'index.php',
'timeout' => 15,
]);
$this->assertEquals(201, $response['headers']['status-code']);
// list functions using request filters
$response = $this->client->call(
Client::METHOD_GET,
'/functions',
array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-response-format' => '1.4.0', // Set response format for 1.4 syntax
], $this->getHeaders()),
[
'queries' => [ 'equal("name", ["Test2"])' ]
]
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertCount(1, $response['body']['functions']);
$this->assertEquals('Test2', $response['body']['functions'][0]['name']);
}
public function testFunctionLogging()
{
// Preparations: Create Function