Skip to content

Commit

Permalink
test: check previous_form_change_id and form_data_record_id on create…
Browse files Browse the repository at this point in the history
… operations
  • Loading branch information
mikevespi committed Nov 30, 2023
1 parent 5ddb79f commit c4dcc8f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion 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(15);
select plan(18);

/** SETUP **/
truncate cif.form_change restart identity;
Expand Down Expand Up @@ -136,6 +136,13 @@ select is (
'When both the committing and pending form changes have changed the same field, the value from the pending should persist'
);

select is (
(select previous_form_change_id from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project'),
3::int,
'When committing, the pending form change gets the committing form change as its previous form change'
);


select is (
(select project_name from cif.project where id = 1),
'Incorrect',
Expand All @@ -154,6 +161,18 @@ select is (
'When the committing form change is creating a project contact, the contact also gets created in the pending revision'
);

select is (
(select previous_form_change_id from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project_contact'),
4::int,
'When committing has an operation of create, the pending form change gets the committing form change as its previous form change'
);

select is (
(select form_data_record_id from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project_attachment'),
1::int,
'When committing has an operation of create, the form_data_record_id propogates to the pending form change'
);

select is (
(select count(*) from cif.form_change where project_revision_id = 2 and form_data_table_name = 'project_attachment'),
1::bigint,
Expand Down

0 comments on commit c4dcc8f

Please sign in to comment.