Added a new Python FX test
This commit is contained in:
parent
a6464ed8b9
commit
c8bdf46a13
|
@ -7,6 +7,7 @@ use Tests\E2E\Client;
|
|||
use Tests\E2E\Scopes\ProjectCustom;
|
||||
use Tests\E2E\Scopes\Scope;
|
||||
use Tests\E2E\Scopes\SideServer;
|
||||
use Utopia\CLI\Console;
|
||||
|
||||
class FunctionsCustomServerTest extends Scope
|
||||
{
|
||||
|
@ -452,20 +453,32 @@ class FunctionsCustomServerTest extends Scope
|
|||
|
||||
public function testENVS():array
|
||||
{
|
||||
$functions = realpath(__DIR__ . '/../../../resources/functions');
|
||||
|
||||
/**
|
||||
* Command for rebuilding code packages:
|
||||
* bash tests/resources/functions/package.sh
|
||||
*/
|
||||
|
||||
$envs = [
|
||||
//[
|
||||
// 'name' => 'php-7.4',
|
||||
// 'code' => $functions.'/php-fx.tar.gz',
|
||||
// 'command' => 'php function.php',
|
||||
//],
|
||||
|
||||
[
|
||||
'name' => 'php-7.4',
|
||||
'code' => realpath(__DIR__ . '/../../../resources/functions/php-fx.tar.gz'),
|
||||
'command' => 'php function.php',
|
||||
],
|
||||
[
|
||||
'language' => 'Python',
|
||||
'version' => '3.8',
|
||||
'name' => 'python-3.8',
|
||||
'code' => realpath(__DIR__ . '/../../../resources/functions/python/code.tar.gz'),
|
||||
'code' => $functions.'/python.tar.gz',
|
||||
'command' => 'python main.py',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($envs as $key => $env) {
|
||||
$language = $env['language'] ?? '';
|
||||
$version = $env['version'] ?? '';
|
||||
$name = $env['name'] ?? '';
|
||||
$code = $env['code'] ?? '';
|
||||
$command = $env['command'] ?? '';
|
||||
|
@ -527,8 +540,6 @@ class FunctionsCustomServerTest extends Scope
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
var_dump($executions['body']['executions'][0]);
|
||||
|
||||
$this->assertEquals($executions['headers']['status-code'], 200);
|
||||
$this->assertEquals($executions['body']['sum'], 1);
|
||||
$this->assertIsArray($executions['body']['executions']);
|
||||
|
@ -537,6 +548,15 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals($executions['body']['executions'][0]['trigger'], 'http');
|
||||
$this->assertEquals($executions['body']['executions'][0]['status'], 'completed');
|
||||
$this->assertEquals($executions['body']['executions'][0]['exitCode'], 0);
|
||||
|
||||
$stdout = explode("\n", $executions['body']['executions'][0]['stdout']);
|
||||
|
||||
$this->assertEquals($stdout[0], $functionId);
|
||||
$this->assertEquals($stdout[1], 'Test '.$name);
|
||||
$this->assertEquals($stdout[2], $tagId);
|
||||
$this->assertEquals($stdout[3], 'http');
|
||||
$this->assertEquals($stdout[4], $language);
|
||||
$this->assertEquals($stdout[5], $version);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
13
tests/resources/functions/package.sh
Normal file
13
tests/resources/functions/package.sh
Normal file
|
@ -0,0 +1,13 @@
|
|||
echo 'Python Packaging'
|
||||
|
||||
cp -r $(pwd)/tests/resources/functions/python $(pwd)/tests/resources/functions/packages/python
|
||||
|
||||
docker run --rm -v $(pwd)/tests/resources/functions/packages/python:/app -w /app appwrite/env-python-3.8:1.0.0 ls -ll .
|
||||
|
||||
docker run --rm -v $(pwd)/tests/resources/functions/packages/python:/app -w /app --env PIP_TARGET=./.appwrite appwrite/env-python-3.8:1.0.0 pip install -r ./requirements.txt --upgrade --ignore-installed
|
||||
|
||||
docker run --rm -v $(pwd)/tests/resources/functions/packages/python:/app -w /app appwrite/env-python-3.8:1.0.0 tar -zcvf code.tar.gz .
|
||||
|
||||
mv $(pwd)/tests/resources/functions/packages/python/code.tar.gz $(pwd)/tests/resources/functions/python.tar.gz
|
||||
|
||||
rm -r $(pwd)/tests/resources/functions/packages/python
|
0
tests/resources/functions/packages/.gitkeep
Normal file
0
tests/resources/functions/packages/.gitkeep
Normal file
BIN
tests/resources/functions/python.tar.gz
Normal file
BIN
tests/resources/functions/python.tar.gz
Normal file
Binary file not shown.
Binary file not shown.
|
@ -21,5 +21,5 @@ print(os.environ["APPWRITE_FUNCTION_TAG"])
|
|||
print(os.environ["APPWRITE_FUNCTION_TRIGGER"])
|
||||
print(os.environ["APPWRITE_FUNCTION_ENV_NAME"])
|
||||
print(os.environ["APPWRITE_FUNCTION_ENV_VERSION"])
|
||||
#print(os.environ["APPWRITE_FUNCTION_EVENT"])
|
||||
#print(os.environ["APPWRITE_FUNCTION_EVENT_PAYLOAD"])
|
||||
print(os.environ["APPWRITE_FUNCTION_EVENT"])
|
||||
print(os.environ["APPWRITE_FUNCTION_EVENT_PAYLOAD"])
|
Loading…
Reference in a new issue