review: Delete execution
This commit is contained in:
parent
9172ff6b14
commit
010f8d3fb8
3 changed files with 84 additions and 55 deletions
|
@ -568,7 +568,7 @@ return [
|
|||
|
||||
Exception::EXECUTION_IN_PROGRESS => [
|
||||
'name' => Exception::EXECUTION_IN_PROGRESS,
|
||||
'description' => 'Can\'t delete ongoing execution. Please wait for execution to finish before you can retry.',
|
||||
'description' => 'Can\'t delete ongoing execution. Please wait for execution to finish before deleting it.',
|
||||
'code' => 400,
|
||||
],
|
||||
|
||||
|
|
|
@ -2044,7 +2044,7 @@ App::delete('/v1/functions/:functionId/executions/:executionId')
|
|||
throw new Exception(Exception::EXECUTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!in_array($execution->getAttribute('status'), ['completed', 'failed'])) {
|
||||
if (!in_array($execution->getAttribute('status'), ['completed', 'failed', 'scheduled'])) {
|
||||
throw new Exception(Exception::EXECUTION_IN_PROGRESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -454,7 +454,6 @@ class FunctionsCustomServerTest extends Scope
|
|||
|
||||
$this->assertEquals(200, $functionDetails['headers']['status-code']);
|
||||
$this->assertEquals('cli', $functionDetails['body']['type']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -671,12 +670,16 @@ class FunctionsCustomServerTest extends Scope
|
|||
/**
|
||||
* Test search queries
|
||||
*/
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([
|
||||
$function = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
'/functions/' . $data['functionId'] . '/deployments',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders(), [
|
||||
'search' => $data['functionId']
|
||||
]));
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals($function['headers']['status-code'], 200);
|
||||
$this->assertEquals(3, $function['body']['total']);
|
||||
|
@ -732,12 +735,16 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals($function['headers']['status-code'], 200);
|
||||
$this->assertCount(0, $function['body']['deployments']);
|
||||
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([
|
||||
$function = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
'/functions/' . $data['functionId'] . '/deployments',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders(), [
|
||||
'search' => 'Test'
|
||||
]));
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals($function['headers']['status-code'], 200);
|
||||
$this->assertEquals(3, $function['body']['total']);
|
||||
|
@ -745,12 +752,16 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertCount(3, $function['body']['deployments']);
|
||||
$this->assertEquals($function['body']['deployments'][0]['$id'], $data['deploymentId']);
|
||||
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments', array_merge([
|
||||
$function = $this->client->call(
|
||||
Client::METHOD_GET,
|
||||
'/functions/' . $data['functionId'] . '/deployments',
|
||||
array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders(), [
|
||||
'search' => 'php-8.0'
|
||||
]));
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals($function['headers']['status-code'], 200);
|
||||
$this->assertEquals(3, $function['body']['total']);
|
||||
|
@ -977,35 +988,6 @@ class FunctionsCustomServerTest extends Scope
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetExecution
|
||||
*/
|
||||
public function testDeleteDeployment($data): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$function = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(204, $function['headers']['status-code']);
|
||||
$this->assertEmpty($function['body']);
|
||||
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(404, $function['headers']['status-code']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetExecution
|
||||
|
@ -1031,6 +1013,53 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals(404, $execution['headers']['status-code']);
|
||||
$this->assertStringContainsString('Execution with the requested ID could not be found', $execution['body']['message']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
*/
|
||||
$execution = $this->client->call(Client::METHOD_POST, '/functions/' . $data['functionId'] . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'async' => true,
|
||||
]);
|
||||
|
||||
$executionId = $execution['body']['$id'] ?? '';
|
||||
$this->assertEquals(202, $execution['headers']['status-code']);
|
||||
|
||||
$execution = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/executions/' . $executionId, array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(400, $execution['headers']['status-code']);
|
||||
$this->assertStringContainsString('execution_in_progress', $execution['body']['type']);
|
||||
$this->assertStringContainsString('Can\'t delete ongoing execution.', $execution['body']['message']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetExecution
|
||||
*/
|
||||
public function testDeleteDeployment($data): array
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$function = $this->client->call(Client::METHOD_DELETE, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(204, $function['headers']['status-code']);
|
||||
$this->assertEmpty($function['body']);
|
||||
|
||||
$function = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/deployments/' . $data['deploymentId'], array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()));
|
||||
|
||||
$this->assertEquals(404, $function['headers']['status-code']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
|
Loading…
Reference in a new issue