LP#1312945: add regression test
authorGalen Charlton <gmc@esilibrary.com>
Tue, 20 May 2014 23:46:02 +0000 (16:46 -0700)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 20 May 2014 23:46:02 +0000 (16:46 -0700)
This adds a test for the change to the
authority.calculate_authority_linking stored function.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg b/Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg
new file mode 100644 (file)
index 0000000..4ec9b36
--- /dev/null
@@ -0,0 +1,59 @@
+BEGIN;
+
+SELECT plan(1);
+
+INSERT INTO authority.record_entry (id, marc, last_xact_id)
+VALUES (999999100, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Doe, Jane</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Alias, Annie</subfield>
+        <subfield code="0">999999101</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Pen-name, Penny</subfield>
+        <subfield code="0">999999102</subfield>
+    </datafield>
+</record>$$, 'test'),
+(999999101, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Alias, Annie</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Doe, Jane</subfield>
+        <subfield code="0">999999100</subfield>
+    </datafield>
+</record>$$, 'test'),
+(999999102, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Pen-name, Penny</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Doe, Jane</subfield>
+        <subfield code="0">999999100</subfield>
+    </datafield>
+</record>$$, 'test');
+
+SELECT is(
+    ARRAY(
+        SELECT (authority.calculate_authority_linking(id, 1, marc::XML)).target
+        FROM authority.record_entry 
+        WHERE id = 999999100 
+        ORDER BY 1
+    ),
+    ARRAY[ 999999101::BIGINT, 999999102::BIGINT ],
+    'retrieve all of the links to other authority records'
+);
+
+ROLLBACK;