From 75513a28b49f65c6b40e0345e56aa0ef7eab243f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 11 May 2017 13:03:16 -0400 Subject: [PATCH] LP#1673857: some test cases Signed-off-by: Galen Charlton Signed-off-by: Josh Stompro Signed-off-by: Galen Charlton --- Open-ILS/src/perlmods/t/21-QueryParser.t | 3 +- Open-ILS/src/sql/Pg/t/copy_tags.pg | 55 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/t/copy_tags.pg diff --git a/Open-ILS/src/perlmods/t/21-QueryParser.t b/Open-ILS/src/perlmods/t/21-QueryParser.t index 81bf051be5..67a06353af 100644 --- a/Open-ILS/src/perlmods/t/21-QueryParser.t +++ b/Open-ILS/src/perlmods/t/21-QueryParser.t @@ -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 index 0000000000..249d7a0e9e --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/copy_tags.pg @@ -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; -- 2.43.2