]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg
LP#1554714 Add explicit phantomjs-prebuilt dependency
[working/Evergreen.git] / Open-ILS / src / sql / Pg / t / regress / lp957466_update_date_and_source.pg
1 BEGIN;
2
3 SELECT plan(4);
4
5 -------------------------
6 -- Setup test environment
7 --   User w/ library card
8 --   Vandelay settings (merge profile, queue)
9 --   "Pre-loaded" bib record to be overlayed
10 --   Matching bib record added to Vandelay queue
11 --     including 905u with user barcode
12 -------------------------
13
14 INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name,
15             passwd, first_given_name, expire_date, dob, suffix)
16     VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST',
17             NOW() + '3 years'::INTERVAL, NULL, NULL);
18
19 INSERT INTO actor.card (barcode, usr)
20     VALUES ('TEST_BARCODE', CURRVAL('actor.usr_id_seq'));
21
22 UPDATE actor.usr
23     SET card = CURRVAL('actor.card_id_seq')
24     WHERE id = CURRVAL('actor.usr_id_seq');
25
26 INSERT INTO vandelay.merge_profile (owner, name, preserve_spec)
27     VALUES (1, 'TEST', '901c');
28
29 --XXX: Do we need to create a custom item_attr_def?
30 --     If def 1 was deleted from an install, this will break
31 INSERT INTO vandelay.bib_queue (owner, name, item_attr_def)
32     VALUES (CURRVAL('actor.usr_id_seq'), 'TEST', 1);
33
34 INSERT INTO biblio.record_entry (id, edit_date, last_xact_id, marc)
35     VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST',
36             '<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"><leader>00374nam a22001212  4500</leader><controlfield tag="001">A101401-2143164</controlfield><controlfield tag="005">20140506000000.0</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9780199588480 (Trade Paper)</subfield><subfield code="c">USD 11.95 List</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Haigh, John</subfield><subfield code="e">Author</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Probability</subfield></datafield><datafield tag="260" ind1=" " ind2=" "><subfield code="b">Oxford University Press, Incorporated</subfield><subfield code="c">2012-05-04</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">144 p.</subfield><subfield code="c">16..84 l. X 11..63 w. in.</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="t">biblio</subfield></datafield></record>');
37
38 INSERT INTO vandelay.queued_bib_record (queue, bib_source, purpose, marc)
39     SELECT CURRVAL('vandelay.queue_id_seq'), 2, 'overlay',
40             '<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"><leader>00374nam a22001212  4500</leader><controlfield tag="001">A101401-2143164</controlfield><controlfield tag="005">20140506000000.0</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9780199588480 (Trade Paper)</subfield><subfield code="c">USD 11.95 List</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Haigh, John</subfield><subfield code="e">Author</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Probability</subfield></datafield><datafield tag="260" ind1=" " ind2=" "><subfield code="b">Oxford University Press, Incorporated</subfield><subfield code="c">2012-05-04</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">144 p.</subfield><subfield code="c">16..84 l. X 11..63 w. in.</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="t">biblio</subfield><subfield code="c">1234512345</subfield></datafield><datafield tag="905" ind1=" " ind2=" "><subfield code="u">'
41             || barcode || '</subfield></datafield></record>'
42     FROM actor.card
43     WHERE id = CURRVAL('actor.card_id_seq');
44
45 -----------------------
46 -- Import the record --
47 -----------------------
48 SELECT ok(
49     (
50         SELECT vandelay.overlay_bib_record( queued_record, eg_record,
51             CURRVAL('vandelay.merge_profile_id_seq')::int )
52         FROM vandelay.bib_match
53         WHERE queued_record = CURRVAL('vandelay.queued_record_id_seq')
54     ),
55     'Function call succeeded'
56 );
57
58 ---------------------------------
59 -- Test for new values of editor,
60 -- edit date, and source
61 ---------------------------------
62 SELECT is(
63     (SELECT editor::bigint FROM biblio.record_entry ORDER BY id DESC LIMIT 1),
64     CURRVAL('actor.usr_id_seq'),
65     'Editor was updated'
66 );
67
68 SELECT is(
69     (SELECT edit_date::date FROM biblio.record_entry ORDER BY id DESC LIMIT 1),
70     CURRENT_DATE,
71     'Edit Date was updated'
72 );
73
74 SELECT is(
75     (SELECT source FROM biblio.record_entry ORDER BY id DESC LIMIT 1),
76     2,
77     'Record source was updated'
78 );
79
80 ROLLBACK;