Merge pull request #8547 from appwrite/fix-templateBranch-in-request-filter

Default fallback to  for templateBranch
This commit is contained in:
Christy Jacob 2024-08-18 18:41:48 +04:00 committed by GitHub
commit 07525350b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 3 deletions

View file

@ -14,7 +14,7 @@ class V18 extends Filter
unset($content['otp']);
break;
case 'functions.create':
$content['templateVersion'] = $content['templateBranch'];
$content['templateVersion'] = $content['templateBranch'] ?? "";
unset($content['templateBranch']);
break;
}

View file

@ -454,8 +454,8 @@ class FunctionsCustomServerTest extends Scope
$entrypoint = null;
$rootDirectory = null;
$commands = null;
foreach($template['body']['runtimes'] as $runtime) {
if($runtime["name"] !== $runtimeName) {
foreach ($template['body']['runtimes'] as $runtime) {
if ($runtime["name"] !== $runtimeName) {
continue;
}
@ -2419,4 +2419,30 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']);
}
public function testCreateFunctionWithResponseFormatHeader()
{
$response = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-response-format' => '1.5.0', // add response format header
], $this->getHeaders()), [
'functionId' => ID::unique(),
'name' => 'Test',
'runtime' => 'php-8.0',
'entrypoint' => 'index.php',
'timeout' => 15,
]);
$this->assertEquals(201, $response['headers']['status-code']);
// Cleanup : Delete function
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $response['body']['$id'], [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], []);
$this->assertEquals(204, $response['headers']['status-code']);
}
}