diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 65aaac0caa..c39e3bed21 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -162,6 +162,10 @@ $utopia->delete('/v1/functions/:functionId') throw new Exception('Function not found', 404); } + if (!$projectDB->deleteDocument($function->getId())) { + throw new Exception('Failed to remove function from DB', 500); + } + $response->noContent(); } ); @@ -304,6 +308,10 @@ $utopia->delete('/v1/functions/:functionId/tags/:tagId') throw new Exception('Tag not found', 404); } + if (!$projectDB->deleteDocument($tag->getId())) { + throw new Exception('Failed to remove tag from DB', 500); + } + $response->noContent(); } ); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index a346ec61d1..f30d7a9b93 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -170,4 +170,34 @@ class FunctionsConsoleServerTest extends Scope return $data; } + + /** + * @depends testUpdate + */ + public function testDelete($data):array + { + /** + * Test for SUCCESS + */ + $function = $this->client->call(Client::METHOD_DELETE, '/functions/'.$data['functionId'], 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'], 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; + } } \ No newline at end of file diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index cf0fd50bd3..be3ec15a93 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -186,6 +186,13 @@ trait StorageBase $this->assertEquals(204, $file['headers']['status-code']); $this->assertEmpty($file['body']); + + $file = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(404, $file['headers']['status-code']); /** * Test for FAILURE