Skip to content

Commit

Permalink
test: add create and mutual update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevespi committed Nov 21, 2023
1 parent cb1a6a0 commit d973423
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion schema/revert/mutations/commit_form_change_internal.sql
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion schema/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ computed_columns/form_change_actual_performance_milestone_amount [computed_colum
functions/handle_milestone_form_change_commit [functions/[email protected]] 2023-09-29T20:17:51Z Sepehr Sobhani <[email protected]> # Update commit handler to fix the issue with archiving milestones
@1.15.0 2023-10-03T21:35:32Z Sepehr Sobhani <[email protected]> # release v1.15.0
@1.16.0 2023-10-24T17:15:40Z Dylan Leard <[email protected]> # release v1.16.0

functions/jsonb_minus 2023-10-30T19:55:55Z Mike Vesprini <[email protected]> # Function to provide the object difference between two jsonb objects
mutations/commit_form_change_internal [mutations/[email protected]] 2023-10-30T21:34:15Z Mike Vesprini <[email protected]> # Handle rebasing when committing with another pending revision on the same project"
mutations/commit_project_revision [mutations/[email protected]] 2023-10-31T00:07:01Z Mike Vesprini <[email protected]> # Update function to pass new parameters to commit_form_change_internal
13 changes: 11 additions & 2 deletions schema/test/unit/mutations/commit_form_change_internal_test.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
begin;

select plan(10);
select plan(11);

/** SETUP **/
truncate cif.form_change restart identity;
Expand Down Expand Up @@ -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', '[email protected]');

Expand Down Expand Up @@ -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',
Expand All @@ -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);

Expand Down

0 comments on commit d973423

Please sign in to comment.