From: Galen Charlton Date: Fri, 23 Oct 2015 17:04:17 +0000 (+0000) Subject: LP#1505286: add pgTAP tests X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=24a7665db9713837148ce1ccd5480e46b63e3d4a;p=evergreen%2Fpines.git LP#1505286: add pgTAP tests Signed-off-by: Galen Charlton Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/sql/Pg/t/search_limit_facet_fetch.pg b/Open-ILS/src/sql/Pg/t/search_limit_facet_fetch.pg new file mode 100644 index 0000000000..86023ce969 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/search_limit_facet_fetch.pg @@ -0,0 +1,85 @@ +BEGIN; + +SELECT plan(4); + +INSERT INTO biblio.record_entry (id, last_xact_id, marc) +VALUES (999999998, 'pgtap', ' + 00531nam a2200157 a 4500 + 20080729170300.0 + t19981999enka 0 eng + + test-value + + + subject 1 + + + subject 2 + + + subject 3 + + + subject 4 + + + subject 5 + + + subject 6 + + + subject 7 + + + subject 8 + + + subject 9 + + + subject 10 + +'); + +-- These tests assume that one subject facet field is defined + +SELECT is( + ( + SELECT COUNT(*) FROM search.facets_for_record_set('{}', '{999999998}') + ), + 10::BIGINT, + '10 subject facets retrieved' +); + +UPDATE config.global_flag SET value = '5' WHERE name = 'search.max_facets_per_field'; +SELECT is( + ( + SELECT COUNT(*) FROM search.facets_for_record_set('{}', '{999999998}') + ), + 5::BIGINT, + '5 subject facets retrieved after setting limit' +); + +SELECT is( + ( + SELECT COUNT(*) FROM ( + SELECT search.facets_for_metarecord_set('{}', array_accum(metarecord)) + FROM metabib.metarecord_source_map + WHERE source = 999999998 + ) x + ), + 5::BIGINT, + 'Works for metarecord sets too' +); + +SELECT is( + ( + SELECT COUNT(*) FROM search.facets_for_record_set('{subject}', '{999999998}') + ), + 0::BIGINT, + 'Zero subject facets retrieved after excluding subject facets' +); + +SELECT * FROM finish(); +ROLLBACK;