Merge pull request #4506 from karniv00l/user-not-found-exception

Fix User not found exception
This commit is contained in:
Christy Jacob
2022-12-20 13:25:35 +05:30
committed by GitHub
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -414,7 +414,7 @@ App::get('/v1/users/:userId')
$user = $dbForProject->getDocument('users', $userId);
if ($user->isEmpty()) {
throw new Exception('User not found', 404, Exception::USER_NOT_FOUND);
throw new Exception(Exception::USER_NOT_FOUND);
}
$response->dynamic($user, Response::MODEL_USER);
+13
View File
@@ -644,6 +644,19 @@ trait UsersBase
$this->assertIsInt($users['body']['total']);
$this->assertGreaterThan(0, $users['body']['total']);
/**
* Test for FAILURE
*/
$user = $this->client->call(Client::METHOD_GET, '/users/non_existent', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 404);
$this->assertEquals($user['body']['code'], 404);
$this->assertEquals($user['body']['message'], 'User with the requested ID could not be found.');
$this->assertEquals($user['body']['type'], 'user_not_found');
return $data;
}