Add pagination on query find_articles_versions_by_*

This commit is contained in:
2019-09-05 17:09:05 +02:00
parent 4990015769
commit 6423491be3
3 changed files with 29 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ declare
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01"}';
created_article json := '{"version_id":"933b6a1b-50c9-42b6-989f-c02a57814ef9", "title": "Love the world", "anonymous": false, "content": "bla bal bla", "tags": ["love", "test"]}';
selected_article json;
selected_total int;
begin
-- insert user for context
select insert_user(created_user) into created_user;
@@ -29,14 +30,16 @@ begin
assert (created_article->>'version_number')::int = 2, format('version_number must be equal to 2, %s instead', created_article->>'version_number');
-- get articles versions by version_id
select find_articles_versions_by_version_id((created_article->>'version_id')::uuid) into selected_article;
select resource, total into selected_article, selected_total from find_articles_versions_by_version_id((created_article->>'version_id')::uuid);
assert selected_article#>>'{0,title}' = 'Love the world', format('title must be "Love the world", %s', selected_article#>>'{0,title}');
assert (selected_article#>>'{0,version_number}')::int = 2, format('version_id must be 2, %s instead', selected_article#>>'{0,version_number}');
assert selected_total = 2, format('the total must be 2, %s instead', selected_total);
-- get articles versions by id
select find_articles_versions_by_id((created_article->>'id')::uuid) into selected_article;
select resource, total into selected_article, selected_total from find_articles_versions_by_id((created_article->>'id')::uuid);
assert selected_article#>>'{0,title}' = 'Love the world', format('title must be "Love the world", %s', selected_article#>>'{0,title}');
assert (selected_article#>>'{0,version_number}')::int = 2, format('version_id must be 2, %s instead', selected_article#>>'{0,version_number}');
assert selected_total = 2, format('the total must be 2, %s instead', selected_total);
-- get article by id and check the title
select find_article_by_id((created_article->>'id')::uuid) into selected_article;