From d97342346808d9f599aa3d2f1b3e11f66ba21fc6 Mon Sep 17 00:00:00 2001 From: Mike Vesprini Date: Mon, 20 Nov 2023 17:22:36 -0800 Subject: [PATCH] test: add create and mutual update tests --- .../mutations/commit_form_change_internal.sql | 1 - schema/sqitch.plan | 1 - .../mutations/commit_form_change_internal_test.sql | 13 +++++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/schema/revert/mutations/commit_form_change_internal.sql b/schema/revert/mutations/commit_form_change_internal.sql index 1e1e8c5f9a..801d43f9d5 100644 --- a/schema/revert/mutations/commit_form_change_internal.sql +++ b/schema/revert/mutations/commit_form_change_internal.sql @@ -1,7 +1,6 @@ -- Deploy cif:mutations/commit_form_change to pg begin; --- drop function if exists cif_private.commit_form_change_internal(cif.form_change, int); create or replace function cif_private.commit_form_change_internal(fc cif.form_change) returns cif.form_change as $$ declare diff --git a/schema/sqitch.plan b/schema/sqitch.plan index 858c048e5f..14bd672763 100644 --- a/schema/sqitch.plan +++ b/schema/sqitch.plan @@ -364,7 +364,6 @@ computed_columns/form_change_actual_performance_milestone_amount [computed_colum functions/handle_milestone_form_change_commit [functions/handle_milestone_form_change_commit@1.14.0] 2023-09-29T20:17:51Z Sepehr Sobhani # Update commit handler to fix the issue with archiving milestones @1.15.0 2023-10-03T21:35:32Z Sepehr Sobhani # release v1.15.0 @1.16.0 2023-10-24T17:15:40Z Dylan Leard # release v1.16.0 - functions/jsonb_minus 2023-10-30T19:55:55Z Mike Vesprini # Function to provide the object difference between two jsonb objects mutations/commit_form_change_internal [mutations/commit_form_change_internal@1.15.0] 2023-10-30T21:34:15Z Mike Vesprini # Handle rebasing when committing with another pending revision on the same project" mutations/commit_project_revision [mutations/commit_project_revision@1.15.0] 2023-10-31T00:07:01Z Mike Vesprini # Update function to pass new parameters to commit_form_change_internal diff --git a/schema/test/unit/mutations/commit_form_change_internal_test.sql b/schema/test/unit/mutations/commit_form_change_internal_test.sql index aaad949fc2..fb29d9d902 100644 --- a/schema/test/unit/mutations/commit_form_change_internal_test.sql +++ b/schema/test/unit/mutations/commit_form_change_internal_test.sql @@ -1,6 +1,6 @@ begin; -select plan(10); +select plan(11); /** SETUP **/ truncate cif.form_change restart identity; @@ -80,7 +80,7 @@ select is( -- Test the concurrent revision functinality -truncate table cif.project, cif.operator restart identity cascade; +truncate table cif.project, cif.operator, cif.contact restart identity cascade; insert into cif.operator(legal_name) values ('test operator'); insert into cif.contact(given_name, family_name, email) values ('John', 'Test', 'foo@abc.com'); @@ -122,8 +122,11 @@ update cif.form_change set new_form_data='{ where project_revision_id=3 and form_data_table_name='project'; +select cif.add_contact_to_revision(3, 1, 1); + select cif.commit_project_revision(3); +-- Both committing and pending project revisions have made changes to the project form. select is ( (select new_form_data->>'projectName' from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project'), 'Correct', @@ -142,6 +145,12 @@ select is ( 'When the commiting form change has updated a field that the pending has not, it updates the pending form change' ); +select is ( + (select new_form_data from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project_contact'), + '{"contactId": 1, "projectId": 1, "contactIndex": 1}'::jsonb, + 'When the committing form change has an operation create, the resource also gets created in the pending revision' +); + -- Commit the ammednment select cif.commit_project_revision(2);