feat: improve test
This commit is contained in:
parent
1024c98bb2
commit
0e773fefdf
1 changed files with 6 additions and 8 deletions
|
@ -4,7 +4,6 @@ namespace Tests\E2E\Services\Functions;
|
||||||
|
|
||||||
use Appwrite\Tests\Retry;
|
use Appwrite\Tests\Retry;
|
||||||
use CURLFile;
|
use CURLFile;
|
||||||
use DateTime;
|
|
||||||
use Tests\E2E\Client;
|
use Tests\E2E\Client;
|
||||||
use Tests\E2E\Scopes\ProjectCustom;
|
use Tests\E2E\Scopes\ProjectCustom;
|
||||||
use Tests\E2E\Scopes\Scope;
|
use Tests\E2E\Scopes\Scope;
|
||||||
|
@ -192,7 +191,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
], [
|
], [
|
||||||
'functionId' => ID::unique(),
|
'functionId' => ID::unique(),
|
||||||
'name' => 'Test',
|
'name' => 'Test',
|
||||||
'execute' => [Role::any()->toString()],
|
'execute' => [Role::user($this->getUser()['$id'])->toString()],
|
||||||
'runtime' => 'php-8.0',
|
'runtime' => 'php-8.0',
|
||||||
'entrypoint' => 'index.php',
|
'entrypoint' => 'index.php',
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
|
@ -227,7 +226,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'async' => true,
|
'async' => true,
|
||||||
'scheduledAt' => $futureTime->format(DateTime::ATOM),
|
'scheduledAt' => $futureTime->format(\DateTime::ATOM),
|
||||||
'path' => '/custom',
|
'path' => '/custom',
|
||||||
'method' => 'GET'
|
'method' => 'GET'
|
||||||
]);
|
]);
|
||||||
|
@ -237,7 +236,6 @@ class FunctionsCustomClientTest extends Scope
|
||||||
|
|
||||||
$executionId = $execution['body']['$id'];
|
$executionId = $execution['body']['$id'];
|
||||||
|
|
||||||
// 10 seconds delay
|
|
||||||
sleep(10);
|
sleep(10);
|
||||||
|
|
||||||
$start = \microtime(true);
|
$start = \microtime(true);
|
||||||
|
@ -252,11 +250,11 @@ class FunctionsCustomClientTest extends Scope
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\microtime(true) - $start > 4) {
|
if (\microtime(true) - $start > 5) {
|
||||||
$this->fail('Execution did not complete within 4 seconds of schedule');
|
$this->fail('Execution did not complete within 5 seconds of schedule');
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(500000);
|
usleep(500000); // 0.5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals(200, $execution['headers']['status-code']);
|
$this->assertEquals(200, $execution['headers']['status-code']);
|
||||||
|
@ -275,7 +273,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'async' => false,
|
'async' => false,
|
||||||
'scheduledAt' => $futureTime->format(DateTime::ATOM),
|
'scheduledAt' => $futureTime->format(\DateTime::ATOM),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(400, $execution['headers']['status-code']);
|
$this->assertEquals(400, $execution['headers']['status-code']);
|
||||||
|
|
Loading…
Reference in a new issue