Fix sql test and add Command for lanch all sql test

This commit is contained in:
2020-02-07 02:07:13 +01:00
parent de6ca63165
commit 2048c71881
6 changed files with 79 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
<configuration default="false" name="All Tests + Lint" type="JUnit" factoryName="JUnit" show_console_on_std_err="true"> <configuration default="false" name="All Tests + Lint" type="JUnit" factoryName="JUnit" show_console_on_std_err="true">
<output_file path="$PROJECT_DIR$/var/log/test/out.log" is_save="true" /> <output_file path="$PROJECT_DIR$/var/log/test/out.log" is_save="true" />
<module name="dcproject.test" /> <module name="dcproject.test" />
<useClassPathOnly />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="11" /> <option name="ALTERNATIVE_JRE_PATH" value="11" />
<option name="PACKAGE_NAME" value="fr.dcproject" /> <option name="PACKAGE_NAME" value="fr.dcproject" />
@@ -20,6 +21,7 @@
<method v="2"> <method v="2">
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Lint" run_configuration_type="GradleRunConfiguration" /> <option name="RunConfigurationTask" enabled="true" run_configuration_name="Lint" run_configuration_type="GradleRunConfiguration" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="Test All SQL" run_configuration_type="RunSql" />
</method> </method>
</configuration> </configuration>
</component> </component>

71
.idea/runConfigurations/Test_All_SQL.xml generated Normal file
View File

@@ -0,0 +1,71 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test All SQL" type="RunSql" factoryName="Run SQL">
<option name="files">
<list>
<option value="$PROJECT_DIR$/src/main/resources/sql/migrations/0000-init_schema.down.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/migrations/0000-init_schema.up.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/find_article_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/find_articles.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/find_articles_versions_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/find_articles_versions_by_version_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/find_last_article_by_version_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/article/upsert_article.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizen_by_email.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizen_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizen_by_id_with_user.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizen_by_user_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizen_by_username.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/find_citizens.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/insert_citizen_with_user.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/citizen/upsert_citizen.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/comment.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/edit_comment.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/find_comment_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/find_comments_by_citizen.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/find_comments_by_parent.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/comment/find_comments_by_target.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/create_title_in_constitution.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/find_constitution_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/find_constitution_title_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/find_constitution_titles_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/find_constitutions.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/constitution/upsert_constitution.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/follow/find_follows_article_by_citizen.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/follow/find_follows_by_citizen.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/follow/find_follows_constitution_by_citizen.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/follow/follow.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/follow/unfollow.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/helpers/find_reference_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/helpers/random_between.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/opinion/count_opinion.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/opinion/opinion.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/user/change_user_password.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/user/check_user.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/user/find_user_by_id.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/user/find_user_by_username.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/user/insert_user.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/vote/vote.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/vote/count_vote.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/vote/find_citizen_votes_by_target_ids.sql" />
<option value="$PROJECT_DIR$/src/main/resources/sql/functions/vote/find_votes_by_citizen.sql" />
<option value="$PROJECT_DIR$/src/test/sql/user.sql" />
<option value="$PROJECT_DIR$/src/test/sql/citizen.sql" />
<option value="$PROJECT_DIR$/src/test/sql/article.sql" />
<option value="$PROJECT_DIR$/src/test/sql/constitution.sql" />
<option value="$PROJECT_DIR$/src/test/sql/comment.sql" />
<option value="$PROJECT_DIR$/src/test/sql/follow.sql" />
<option value="$PROJECT_DIR$/src/test/sql/vote.sql" />
<option value="$PROJECT_DIR$/src/test/sql/opinion.sql" />
</list>
</option>
<option name="targets">
<list>
<Target>
<option name="dsId" value="a9a6d0e9-327d-4e7d-9b93-3cb6f7948866" />
<option name="namespace" value="database/&quot;test&quot;/schema/&quot;public&quot;" />
</Target>
</list>
</option>
<method v="2" />
</configuration>
</component>

View File

@@ -5,7 +5,7 @@ declare
created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}'; created_user json := '{"username": "george", "plain_password": "azerty", "roles": ["ROLE_USER"]}';
_user_id uuid; _user_id uuid;
created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com"}'; created_citizen json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com"}';
created_citizen_with_user json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel@gmail.com", "user":{"username": "george junior", "plain_password": "azerty", "roles": ["ROLE_USER"]}}'; created_citizen_with_user json := '{"name": {"first_name":"George", "last_name":"MICHEL"}, "birthday": "2001-01-01", "email":"george.michel2@gmail.com", "user":{"username": "george junior", "plain_password": "azerty", "roles": ["ROLE_USER"]}}';
selected_citizen json; selected_citizen json;
begin begin
-- insert user for context -- insert user for context

View File

@@ -126,15 +126,12 @@ begin
select resource into _find_comments_by_target_result select resource into _find_comments_by_target_result
from find_comments_by_target((created_article->>'id')::uuid); from find_comments_by_target((created_article->>'id')::uuid);
assert json_array_length(_find_comments_by_target_result) = 3, assert json_array_length(_find_comments_by_target_result) = 1,
'the result should contain 3 comment, ' || json_array_length(_find_comments_by_target_result) || ' returned'; 'the result should contain 1 comment, ' || json_array_length(_find_comments_by_target_result) || ' returned';
assert (_find_comments_by_target_result#>>'{0,content}') = 'edited content', 'the first content must contain "edited content", "' || (_find_comments_by_target_result#>>'{0,content}') || '" returned'; assert (_find_comments_by_target_result#>>'{0,content}') = 'edited content', 'the first content must contain "edited content", "' || (_find_comments_by_target_result#>>'{0,content}') || '" returned';
assert (_find_comments_by_target_result#>>'{1,content}') = 'God not exist', 'the second content must contain "God not exist", "' || (_find_comments_by_target_result#>>'{1,content}') || '" returned';
assert (_find_comments_by_target_result#>>'{2,content}') = 'are you really sure ?', 'the third content must contain "are you really sure ?", "' || (_find_comments_by_target_result#>>'{2,content}') || '" returned';
raise notice '%', (_find_comments_by_target_result#>>'{0,id}');
select resource into _find_comments_by_parent_result select resource into _find_comments_by_parent_result
from find_comments_by_parent((_find_comments_by_target_result#>>'{1,id}')::uuid); from find_comments_by_parent(_comment_id_response);
assert json_array_length(_find_comments_by_parent_result) = 1, assert json_array_length(_find_comments_by_parent_result) = 1,
'the result should contain 1 comment, ' || json_array_length(_find_comments_by_parent_result) || ' returned'; 'the result should contain 1 comment, ' || json_array_length(_find_comments_by_parent_result) || ' returned';
assert (_find_comments_by_parent_result#>>'{0,content}') = 'are you really sure ?', 'the third content must contain "are you really sure ?", "' || (_find_comments_by_parent_result#>>'{1,content}') || '" returned'; assert (_find_comments_by_parent_result#>>'{0,content}') = 'are you really sure ?', 'the third content must contain "are you really sure ?", "' || (_find_comments_by_parent_result#>>'{1,content}') || '" returned';

View File

@@ -22,7 +22,7 @@ declare
"last_name": "Doe" "last_name": "Doe"
}, },
"birthday": "2002-01-01", "birthday": "2002-01-01",
"email":"george.michel@gmail.com" "email":"george.michel2@gmail.com"
} }
$json$; $json$;
begin begin

View File

@@ -22,7 +22,7 @@ declare
"last_name": "MICHEL2" "last_name": "MICHEL2"
}, },
"birthday": "2001-01-02", "birthday": "2001-01-02",
"email":"george.michel@gmail.com" "email":"george.michel2@gmail.com"
} }
$json$; $json$;
created_article json := $json$ created_article json := $json$