1
0
Fork 0
mirror of synced 2024-10-01 01:37:56 +13:00

Comment out Dart test

This commit is contained in:
Matej Bačo 2022-11-12 13:56:23 +00:00
parent f468248f45
commit 23258c6e43

View file

@ -1264,118 +1264,118 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(204, $response['headers']['status-code']); $this->assertEquals(204, $response['headers']['status-code']);
} }
public function testCreateCustomDartExecution() // public function testCreateCustomDartExecution()
{ // {
$name = 'dart-2.15'; // $name = 'dart-2.15';
$folder = 'dart'; // $folder = 'dart';
$code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz"; // $code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz";
$this->packageCode($folder); // $this->packageCode($folder);
$entrypoint = 'main.dart'; // $entrypoint = 'main.dart';
$timeout = 2; // $timeout = 2;
$function = $this->client->call(Client::METHOD_POST, '/functions', array_merge([ // $function = $this->client->call(Client::METHOD_POST, '/functions', array_merge([
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ // ], $this->getHeaders()), [
'functionId' => ID::unique(), // 'functionId' => ID::unique(),
'name' => 'Test ' . $name, // 'name' => 'Test ' . $name,
'runtime' => $name, // 'runtime' => $name,
'events' => [], // 'events' => [],
'schedule' => '', // 'schedule' => '',
'timeout' => $timeout, // 'timeout' => $timeout,
]); // ]);
$functionId = $function['body']['$id'] ?? ''; // $functionId = $function['body']['$id'] ?? '';
$this->assertEquals(201, $function['headers']['status-code']); // $this->assertEquals(201, $function['headers']['status-code']);
/** Create Variables */ // /** Create Variables */
$variable = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/variables', array_merge([ // $variable = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/variables', array_merge([
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ // ], $this->getHeaders()), [
'key' => 'CUSTOM_VARIABLE', // 'key' => 'CUSTOM_VARIABLE',
'value' => 'variable', // 'value' => 'variable',
]); // ]);
$this->assertEquals(201, $variable['headers']['status-code']); // $this->assertEquals(201, $variable['headers']['status-code']);
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge([ // $deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge([
'content-type' => 'multipart/form-data', // 'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ // ], $this->getHeaders()), [
'entrypoint' => $entrypoint, // 'entrypoint' => $entrypoint,
'code' => new CURLFile($code, 'application/x-gzip', basename($code)), // 'code' => new CURLFile($code, 'application/x-gzip', basename($code)),
'activate' => true, // 'activate' => true,
]); // ]);
$deploymentId = $deployment['body']['$id'] ?? ''; // $deploymentId = $deployment['body']['$id'] ?? '';
$this->assertEquals(202, $deployment['headers']['status-code']); // $this->assertEquals(202, $deployment['headers']['status-code']);
// Allow build step to run // // Allow build step to run
sleep(80); // sleep(80);
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ // $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [ // ], $this->getHeaders()), [
'data' => 'foobar', // 'data' => 'foobar',
'async' => true // 'async' => true
]); // ]);
$executionId = $execution['body']['$id'] ?? ''; // $executionId = $execution['body']['$id'] ?? '';
$this->assertEquals(202, $execution['headers']['status-code']); // $this->assertEquals(202, $execution['headers']['status-code']);
$executionId = $execution['body']['$id'] ?? ''; // $executionId = $execution['body']['$id'] ?? '';
sleep(20); // sleep(20);
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $executionId, array_merge([ // $executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions/' . $executionId, array_merge([
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders())); // ], $this->getHeaders()));
$output = json_decode($executions['body']['response'], true); // $output = json_decode($executions['body']['response'], true);
$this->assertEquals(200, $executions['headers']['status-code']); // $this->assertEquals(200, $executions['headers']['status-code']);
$this->assertEquals('completed', $executions['body']['status']); // $this->assertEquals('completed', $executions['body']['status']);
$this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']); // $this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']);
$this->assertEquals('Test ' . $name, $output['APPWRITE_FUNCTION_NAME']); // $this->assertEquals('Test ' . $name, $output['APPWRITE_FUNCTION_NAME']);
$this->assertEquals($deploymentId, $output['APPWRITE_FUNCTION_DEPLOYMENT']); // $this->assertEquals($deploymentId, $output['APPWRITE_FUNCTION_DEPLOYMENT']);
$this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); // $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']);
$this->assertEquals('Dart', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); // $this->assertEquals('Dart', $output['APPWRITE_FUNCTION_RUNTIME_NAME']);
$this->assertEquals('2.15', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); // $this->assertEquals('2.15', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']);
$this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); // $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']);
$this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT_DATA']); // $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT_DATA']);
$this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); // $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']);
$this->assertEquals('', $output['APPWRITE_FUNCTION_USER_ID']); // $this->assertEquals('', $output['APPWRITE_FUNCTION_USER_ID']);
$this->assertEmpty($output['APPWRITE_FUNCTION_JWT']); // $this->assertEmpty($output['APPWRITE_FUNCTION_JWT']);
$this->assertEquals($this->getProject()['$id'], $output['APPWRITE_FUNCTION_PROJECT_ID']); // $this->assertEquals($this->getProject()['$id'], $output['APPWRITE_FUNCTION_PROJECT_ID']);
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([ // $executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders())); // ], $this->getHeaders()));
$this->assertEquals($executions['headers']['status-code'], 200); // $this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['total'], 1); // $this->assertEquals($executions['body']['total'], 1);
$this->assertIsArray($executions['body']['executions']); // $this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']); // $this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId); // $this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
$this->assertEquals($executions['body']['executions'][0]['trigger'], 'http'); // $this->assertEquals($executions['body']['executions'][0]['trigger'], 'http');
$this->assertStringContainsString('foobar', $executions['body']['executions'][0]['response']); // $this->assertStringContainsString('foobar', $executions['body']['executions'][0]['response']);
// Cleanup : Delete function // // Cleanup : Delete function
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [ // $response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
'content-type' => 'application/json', // 'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'], // 'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'], // 'x-appwrite-key' => $this->getProject()['apiKey'],
], []); // ], []);
$this->assertEquals(204, $response['headers']['status-code']); // $this->assertEquals(204, $response['headers']['status-code']);
} // }
#[Retry(count: 1)] #[Retry(count: 1)]
public function testCreateCustomRubyExecution() public function testCreateCustomRubyExecution()