From 31108a7ab247fbdc3b30320ce041d9e32020a055 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 28 Oct 2016 11:40:52 -0400 Subject: [PATCH] LP#1488655: regression test for metarecord remapping This patch contains pgTAP tests for verifying that when the fingerprint of a bib is changed, it remains part of exactly one metarecord (as opposed to being part of both its old and new MRs). Signed-off-by: Galen Charlton Signed-off-by: Rogan Hamby Signed-off-by: Chris Sharp --- .../Pg/t/lp1488655_metarecord_remapping.pg | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/lp1488655_metarecord_remapping.pg diff --git a/Open-ILS/src/sql/Pg/t/lp1488655_metarecord_remapping.pg b/Open-ILS/src/sql/Pg/t/lp1488655_metarecord_remapping.pg new file mode 100644 index 0000000000..92205a3ff6 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/lp1488655_metarecord_remapping.pg @@ -0,0 +1,57 @@ +-- tests to verify that metarecord mapping updates happen correctly +BEGIN; + +SELECT plan(4); + +INSERT INTO biblio.record_entry (last_xact_id, marc) VALUES ( + 'metarecord-remap-test', + $record$ + 02137cam a2200457 a 4500 + ocn694080497 + 20160729104757.0 + 101217s2011 txu b 001 0 eng + + Random Title AFDSDGFJ / + Felix T. Cat. + +$record$); + +SELECT is( + ( + SELECT COUNT(*) FROM metabib.metarecord + WHERE master_record = CURRVAL('biblio.record_entry_id_seq') + )::INT, + 1, + 'unique bib becomes master of just one metarecord' +); +SELECT is( + ( + SELECT COUNT(*) FROM metabib.metarecord_source_map + WHERE source = CURRVAL('biblio.record_entry_id_seq') + )::INT, + 1, + 'unique bib part of just one metarecord mapping' +); + +UPDATE biblio.record_entry +SET marc = REPLACE(marc, 'Random Title AFDSDGFJ', 'Random Title XXDFYLNJ') +WHERE id = CURRVAL('biblio.record_entry_id_seq'); + +SELECT is( + ( + SELECT COUNT(*) FROM metabib.metarecord + WHERE master_record = CURRVAL('biblio.record_entry_id_seq') + )::INT, + 1, + 'LP#1488655: after fingerprint change, bib still master of just one metarecord' +); +SELECT is( + ( + SELECT COUNT(*) FROM metabib.metarecord_source_map + WHERE source = CURRVAL('biblio.record_entry_id_seq') + )::INT, + 1, + 'LP#1488655: after fingerprint change, bib still in just one metarecord mapping' +); + +ROLLBACK; -- 2.43.2