From: Remington Steed Date: Thu, 19 Feb 2015 15:03:18 +0000 (-0500) Subject: LP#957466: Added pgTAP test for db function change X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1bee75f92d9e6fd5157867cbff16f6f3e5b32053;p=evergreen%2Ftadl.git LP#957466: Added pgTAP test for db function change Signed-off-by: Remington Steed Signed-off-by: Dan Wells --- diff --git a/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg b/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg new file mode 100644 index 0000000000..969c31bb86 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg @@ -0,0 +1,80 @@ +BEGIN; + +SELECT plan(4); + +------------------------- +-- Setup test environment +-- User w/ library card +-- Vandelay settings (merge profile, queue) +-- "Pre-loaded" bib record to be overlayed +-- Matching bib record added to Vandelay queue +-- including 905u with user barcode +------------------------- + +INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, + passwd, first_given_name, expire_date, dob, suffix) + VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST', + NOW() + '3 years'::INTERVAL, NULL, NULL); + +INSERT INTO actor.card (barcode, usr) + VALUES ('TEST_BARCODE', CURRVAL('actor.usr_id_seq')); + +UPDATE actor.usr + SET card = CURRVAL('actor.card_id_seq') + WHERE id = CURRVAL('actor.usr_id_seq'); + +INSERT INTO vandelay.merge_profile (owner, name, preserve_spec) + VALUES (1, 'TEST', '901c'); + +--XXX: Do we need to create a custom item_attr_def? +-- If def 1 was deleted from an install, this will break +INSERT INTO vandelay.bib_queue (owner, name, item_attr_def) + VALUES (CURRVAL('actor.usr_id_seq'), 'TEST', 1); + +INSERT INTO biblio.record_entry (id, edit_date, last_xact_id, marc) + VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST', + '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio'); + +INSERT INTO vandelay.queued_bib_record (queue, bib_source, purpose, marc) + SELECT CURRVAL('vandelay.queue_id_seq'), 2, 'overlay', + '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio1234512345' + || barcode || '' + FROM actor.card + WHERE id = CURRVAL('actor.card_id_seq'); + +----------------------- +-- Import the record -- +----------------------- +SELECT ok( + ( + SELECT vandelay.overlay_bib_record( queued_record, eg_record, + CURRVAL('vandelay.merge_profile_id_seq')::int ) + FROM vandelay.bib_match + WHERE queued_record = CURRVAL('vandelay.queued_record_id_seq') + ), + 'Function call succeeded' +); + +--------------------------------- +-- Test for new values of editor, +-- edit date, and source +--------------------------------- +SELECT is( + (SELECT editor::bigint FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRVAL('actor.usr_id_seq'), + 'Editor was updated' +); + +SELECT is( + (SELECT edit_date::date FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRENT_DATE, + 'Edit Date was updated' +); + +SELECT is( + (SELECT source FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + 2, + 'Record source was updated' +); + +ROLLBACK;