Refactor command execution to use Utopia\Command

This commit is contained in:
Torsten Dittmann
2026-04-17 18:31:48 +04:00
parent eddd159af8
commit 03be7ade3d
15 changed files with 308 additions and 81 deletions
@@ -8,6 +8,7 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Command;
use Utopia\Console;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
@@ -83,7 +84,15 @@ class WebhooksCustomServerTest extends Scope
$stdout = '';
$folder = 'timeout';
$code = realpath(__DIR__ . '/../../../resources/functions') . "/{$folder}/code.tar.gz";
Console::execute('cd ' . realpath(__DIR__ . "/../../../resources/functions") . "/{$folder} && tar --exclude code.tar.gz --exclude node_modules -czf code.tar.gz .", '', $stdout, $stderr);
$folderPath = realpath(__DIR__ . '/../../../resources/functions') . "/{$folder}";
$packageFunctionCommand = (new Command('tar'))
->option('--exclude', 'code.tar.gz')
->option('--exclude', 'node_modules')
->flag('-czf')
->argument($code)
->option('-C', $folderPath)
->argument('.');
Console::execute($packageFunctionCommand, '', $stdout, $stderr);
// Create variable first
$this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/variables', array_merge([
@@ -734,7 +743,15 @@ class WebhooksCustomServerTest extends Scope
$stdout = '';
$folder = 'timeout';
$code = realpath(__DIR__ . '/../../../resources/functions') . "/{$folder}/code.tar.gz";
Console::execute('cd ' . realpath(__DIR__ . "/../../../resources/functions") . "/{$folder} && tar --exclude code.tar.gz --exclude node_modules -czf code.tar.gz .", '', $stdout, $stderr);
$folderPath = realpath(__DIR__ . '/../../../resources/functions') . "/{$folder}";
$packageFunctionCommand = (new Command('tar'))
->option('--exclude', 'code.tar.gz')
->option('--exclude', 'node_modules')
->flag('-czf')
->argument($code)
->option('-C', $folderPath)
->argument('.');
Console::execute($packageFunctionCommand, '', $stdout, $stderr);
$deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge([
'content-type' => 'multipart/form-data',