From 5dc79e84f0bd9e79c6c0e21acc6d39a1bc6307cf Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 28 Apr 2016 11:20:29 -0400 Subject: [PATCH] LP#1569884: add regression test This pgTAP test verifies that if you logically delete a monograph part, you can subsequently add a new one with the same label as that of the deleted one. Signed-off-by: Galen Charlton --- .../t/regress/lp1569884_readd_deleted_bmp.sql | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/regress/lp1569884_readd_deleted_bmp.sql diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1569884_readd_deleted_bmp.sql b/Open-ILS/src/sql/Pg/t/regress/lp1569884_readd_deleted_bmp.sql new file mode 100644 index 0000000000..ecb468f925 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/regress/lp1569884_readd_deleted_bmp.sql @@ -0,0 +1,52 @@ +BEGIN; + +SELECT plan(4); + +INSERT INTO biblio.record_entry (id, last_xact_id, marc) +VALUES (999999998, 'pgtap', ' + 00531nam a2200157 a 4500 + 20080729170300.0 + t19981999enka 0 eng + + test-value + +'); + +INSERT INTO biblio.monograph_part(record, label) VALUES (999999998, 'Part 1'); + +SELECT is( + label, + 'Part 1', + 'LP#1569884: new monograph parts start out active' +) +FROM biblio.monograph_part +WHERE record = 999999998 +AND NOT deleted; + +DELETE FROM biblio.monograph_part WHERE record = 999999998; + +SELECT is( + deleted, + TRUE, + 'LP#1569884: deleting monograph part sets deleted flag' +) +FROM biblio.monograph_part +WHERE record = 999999998 +AND label = 'Part 1'; + +SELECT lives_ok( + $$INSERT INTO biblio.monograph_part(record, label) VALUES (999999998, 'Part 1')$$, + 'LP#1569884: can add monograph part with same label as logically deleted one' +); + +SELECT is( + COUNT(*)::INT, + 1, + 'LP#1569884: one active part with label Part 1' +) +FROM biblio.monograph_part +WHERE record = 999999998 +AND label = 'Part 1' +AND NOT deleted; + +ROLLBACK; -- 2.43.2