diff --git a/resources/functions/user/find_user_by_id.sql b/resources/functions/user/find_user_by_id.sql index d5f8ffa..9833093 100644 --- a/resources/functions/user/find_user_by_id.sql +++ b/resources/functions/user/find_user_by_id.sql @@ -1,4 +1,4 @@ -create or replace procedure find_user_by_id(in id uuid, inout resource json) language plpgsql as +create or replace function find_user_by_id(in id uuid, out resource json) language plpgsql as $$ declare _id alias for id; @@ -9,4 +9,4 @@ begin end; $$; --- drop procedure if exists find_user_by_id(uuid, inout json); \ No newline at end of file +-- drop function if exists find_user_by_id(uuid, inout json); \ No newline at end of file diff --git a/resources/functions/user/find_user_by_username.sql b/resources/functions/user/find_user_by_username.sql index c8c6e4b..717a643 100644 --- a/resources/functions/user/find_user_by_username.sql +++ b/resources/functions/user/find_user_by_username.sql @@ -1,4 +1,4 @@ -create or replace procedure find_user_by_username(in username text, inout resource json) language plpgsql as +create or replace function find_user_by_username(in username text, out resource json) language plpgsql as $$ declare _username alias for username; @@ -9,4 +9,4 @@ begin end; $$; --- drop procedure if exists find_user_by_username(text, inout json); \ No newline at end of file +-- drop function if exists find_user_by_username(text, out json); \ No newline at end of file diff --git a/resources/tests/user.sql b/resources/tests/user.sql index cff7005..ec89e82 100644 --- a/resources/tests/user.sql +++ b/resources/tests/user.sql @@ -11,11 +11,11 @@ begin assert created_user->>'password' is not null, 'password must be generated'; -- get user by there id and check the username is correct - call find_user_by_id((created_user->>'id')::uuid, selected_user); - assert selected_user->>'username' = 'george', 'username must be george'; + select find_user_by_id((created_user->>'id')::uuid) into selected_user; + assert selected_user->>'username' = 'george', format('username must be george, %s instead', selected_user); -- get user by username and check the username is correct - call find_user_by_username(created_user->>'username', selected_user); + select find_user_by_username(created_user->>'username') into selected_user; assert selected_user->>'username' = 'george', 'username must be george'; -- check if user exist with username and password and verify the reterned user