LP#1673857: some test cases
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 11 May 2017 17:03:16 +0000 (13:03 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 24 Jul 2017 15:29:15 +0000 (11:29 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/t/21-QueryParser.t
Open-ILS/src/sql/Pg/t/copy_tags.pg [new file with mode: 0644]

index 81bf051..67a0635 100644 (file)
@@ -40,7 +40,7 @@ is (scalar(@{$QParser->facet_fields()->{'author'}}), 1, "Removed facet field");
 $QParser->remove_facet_class('author');
 is ($QParser->facet_class_count, 1, "Removed facet class");
 
-is ($QParser->filter_count, 28, "Correct number of filters");
+is ($QParser->filter_count, 29, "Correct number of filters");
 is (scalar(@{$QParser->filter_normalizers('skip_check')}), 0, 'No filter normalizers by default');
 $QParser->add_filter_normalizer('skip_check', \&test_filter_norm);
 is (scalar(@{$QParser->filter_normalizers('skip_check')}), 1, 'Added filter normalizer');
@@ -284,6 +284,7 @@ sub init_qp {
     $QParser->add_search_filter( 'skip_check' );
     $QParser->add_search_filter( 'superpage' );
     $QParser->add_search_filter( 'estimation_strategy' );
+    $QParser->add_search_filter( 'copy_tag' );
     $QParser->add_search_modifier( 'available' );
     $QParser->add_search_modifier( 'staff' );
 
diff --git a/Open-ILS/src/sql/Pg/t/copy_tags.pg b/Open-ILS/src/sql/Pg/t/copy_tags.pg
new file mode 100644 (file)
index 0000000..249d7a0
--- /dev/null
@@ -0,0 +1,55 @@
+BEGIN;
+
+-- Plan the tests.
+SELECT plan(4);
+
+INSERT INTO asset.copy_tag(tag_type, label, owner ) VALUES ('bookplate', 'lp1673857_dummy_copy_tag', 1);
+SELECT is(
+  value,
+  'lp1673857_dummy_copy_tag',
+  'Copy tag label can be used to set copy tag value')
+FROM asset.copy_tag
+WHERE tag_type = 'bookplate'
+AND   label = 'lp1673857_dummy_copy_tag'
+AND   owner = 1;
+
+UPDATE asset.copy_tag
+SET    value = 'jane q. smith'
+WHERE tag_type = 'bookplate'
+AND   label = 'lp1673857_dummy_copy_tag'
+AND   owner = 1;
+
+SELECT is(
+  COUNT(*),
+  1::BIGINT,
+  'Copy tag value FTS works #1'
+)
+FROM asset.copy_tag
+WHERE tag_type = 'bookplate'
+AND   label = 'lp1673857_dummy_copy_tag'
+AND   value @@ to_tsquery('jane')
+AND   owner = 1;
+
+SELECT is(
+  COUNT(*),
+  1::BIGINT,
+  'Copy tag value FTS works #2'
+)
+FROM asset.copy_tag
+WHERE tag_type = 'bookplate'
+AND   label = 'lp1673857_dummy_copy_tag'
+AND   value @@ to_tsquery('jane & smith')
+AND   owner = 1;
+
+SELECT is(
+  COUNT(*),
+  0::BIGINT,
+  'Copy tag value FTS works #3'
+)
+FROM asset.copy_tag
+WHERE tag_type = 'bookplate'
+AND   label = 'lp1673857_dummy_copy_tag'
+AND   value @@ to_tsquery('jane & wesson')
+AND   owner = 1;
+
+ROLLBACK;