feature #12: add Constitution tests
This commit is contained in:
@@ -7,16 +7,18 @@ begin
|
||||
delete from title;
|
||||
delete from constitution;
|
||||
|
||||
insert into constitution (version_id, created_by_id, title, annonymous)
|
||||
insert into constitution (id, version_id, created_by_id, title, annonymous)
|
||||
select
|
||||
uuid_generate_v4(),
|
||||
uuid_in(md5('constitution'||row_number() over ())::cstring),
|
||||
uuid_in(md5('constitution_v'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
'title' || row_number() over (),
|
||||
row_number() over () % 3 = 0
|
||||
from citizen z;
|
||||
|
||||
insert into title (created_by_id, name, rank, constitution_id)
|
||||
insert into title (id, created_by_id, name, rank, constitution_id)
|
||||
select
|
||||
uuid_in(md5('constitution_title'||row_number() over ())::cstring),
|
||||
c.created_by_id,
|
||||
'name' || row_number() over (),
|
||||
row_number() over (),
|
||||
@@ -24,8 +26,9 @@ begin
|
||||
from constitution c,
|
||||
lateral generate_series(1, 5) g;
|
||||
|
||||
insert into article_in_title (created_by_id, rank, title_id, article_id, constitution_id)
|
||||
insert into article_in_title (id, created_by_id, rank, title_id, article_id, constitution_id)
|
||||
select
|
||||
uuid_in(md5('article_in_title'||row_number() over ())::cstring),
|
||||
ti.created_by_id,
|
||||
row_number() over (),
|
||||
ti.id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
create or replace procedure upsert_constitution(inout resource json)
|
||||
create or replace function upsert_constitution(inout resource json)
|
||||
language plpgsql as
|
||||
$$
|
||||
declare
|
||||
@@ -30,4 +30,4 @@ begin
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop procedure if exists upsert_constitution(inout json);
|
||||
-- drop function if exists upsert_constitution(inout json);
|
||||
45
src/test/resources/feature/constitution.feature
Normal file
45
src/test/resources/feature/constitution.feature
Normal file
@@ -0,0 +1,45 @@
|
||||
Feature: constitution routes
|
||||
|
||||
Scenario: The route for get constitutions must response a 200
|
||||
When I send a "GET" request to "/constitutions"
|
||||
Then the response status code should be 200
|
||||
|
||||
Scenario: The route for get one constitution must response a 200 and return constitution
|
||||
When I send a "GET" request to "/constitutions/0ca489a6-ef68-8bd5-2355-5793d4b3d66c"
|
||||
Then the response status code should be 200
|
||||
And the response should contain object:
|
||||
| id | 0ca489a6-ef68-8bd5-2355-5793d4b3d66c |
|
||||
|
||||
Scenario: The route for create constitution must response a 200 and return object
|
||||
Given I have citizen:
|
||||
| id | 64b7b379-2298-43ec-b428-ba134930cabd |
|
||||
| firstName | Jaque |
|
||||
| lastName | Dupuis |
|
||||
When I send a "POST" request to "/constitutions" with body:
|
||||
"""
|
||||
{
|
||||
"version_id":"15814bb6-8d90-4c6a-a456-c3939a8ec75e",
|
||||
"title":"Hello world!",
|
||||
"annonymous":true,
|
||||
"titles":[
|
||||
{
|
||||
"id":"8156b66f-a9c8-4fd9-8375-a8a1f42ccfd2",
|
||||
"name":"plop",
|
||||
"rank":0,
|
||||
"created_by":{
|
||||
"id":"64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
}
|
||||
}
|
||||
],
|
||||
"created_by":{
|
||||
"id":"64b7b379-2298-43ec-b428-ba134930cabd"
|
||||
},
|
||||
"created_at":null,
|
||||
"version_id":"3311a7af-2a62-4e31-b4cd-889f8ead9737",
|
||||
"version_number":null
|
||||
}
|
||||
"""
|
||||
Then the response status code should be 200
|
||||
And the response should contain object:
|
||||
| version_id | 15814bb6-8d90-4c6a-a456-c3939a8ec75e |
|
||||
| title | Hello world! |
|
||||
Reference in New Issue
Block a user