1
0
Fork 0
mirror of synced 2024-06-01 10:29:48 +12:00

Updated tests and delete methods

This commit is contained in:
Eldad Fux 2020-05-06 15:12:52 +03:00
parent bce90d68b0
commit a3b1e97ebf
3 changed files with 45 additions and 0 deletions

View file

@ -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();
}
);

View file

@ -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;
}
}

View file

@ -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