Refactoring: user fixtures in sql tests

This commit is contained in:
2020-03-06 09:54:58 +01:00
parent 4a4e9651fd
commit 559890000d
11 changed files with 101 additions and 281 deletions

View File

@@ -0,0 +1,16 @@
create or replace function fixture_user(in name text default 'george', out user_id uuid)
language plpgsql as
$$
declare
created_user1 json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
created_user2 json := '{"username": "john", "plain_password": "qwerty", "roles": ["ROLE_USER"]}';
begin
if (name = 'george') then
select insert_user(created_user1) into created_user1;
user_id := created_user1->>'id';
elseif (name = 'john') then
select insert_user(created_user2) into created_user2;
user_id := created_user2->>'id';
end if;
end
$$