From ae94883e05918ee0d3c50aedaec3045187df6ef7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 15 Jun 2015 18:09:01 -0400 Subject: [PATCH] LP#1464709 Non-standard copy status pgtap tests Includes unit test plus a set of live tests. Signed-off-by: Bill Erickson --- .../Pg/live_t/lp1464709-copy-stat-co-ok.live.pg | 48 ++++++++++++++++++++++ Open-ILS/src/sql/Pg/t/lp1464709-copy-stat-co-ok.pg | 29 +++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/live_t/lp1464709-copy-stat-co-ok.live.pg create mode 100644 Open-ILS/src/sql/Pg/t/lp1464709-copy-stat-co-ok.pg diff --git a/Open-ILS/src/sql/Pg/live_t/lp1464709-copy-stat-co-ok.live.pg b/Open-ILS/src/sql/Pg/live_t/lp1464709-copy-stat-co-ok.live.pg new file mode 100644 index 0000000000..2874298ff4 --- /dev/null +++ b/Open-ILS/src/sql/Pg/live_t/lp1464709-copy-stat-co-ok.live.pg @@ -0,0 +1,48 @@ +\set ECHO none +\set QUIET 1 +-- Turn off echo and keep things quiet. + +-- Format the output for nice TAP. +\pset format unaligned +\pset tuples_only true +\pset pager + +-- Revert all changes on failure. +\set ON_ERROR_ROLLBACK 1 +\set ON_ERROR_STOP true +\set QUIET 1 + +-- Load the TAP functions. +BEGIN; + +-- Plan the tests. +SELECT plan(3); + +SELECT is( + fail_part, + NULL, + 'Checkout test Available succeeds' +) FROM action.item_user_circ_test(4, 1, 1); + +-- checkout_ok defaults to false +INSERT into config.copy_status (id, name) VALUES (101, 'lp1464709'); +UPDATE asset.copy SET status = 101 WHERE id = 1; + +SELECT is( + fail_part, + 'asset.copy.status', + 'Checkout test checkout_ok=false fails' +) FROM action.item_user_circ_test(4, 1, 1); + +UPDATE config.copy_status SET checkout_ok = TRUE WHERE name = 'lp1464709'; + +SELECT is( + fail_part, + NULL, + 'Checkout test checkout_ok=true succeeds' +) FROM action.item_user_circ_test(4, 1, 1); + + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; diff --git a/Open-ILS/src/sql/Pg/t/lp1464709-copy-stat-co-ok.pg b/Open-ILS/src/sql/Pg/t/lp1464709-copy-stat-co-ok.pg new file mode 100644 index 0000000000..dfe9a99107 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/lp1464709-copy-stat-co-ok.pg @@ -0,0 +1,29 @@ +\set ECHO none +\set QUIET 1 +-- Turn off echo and keep things quiet. + +-- Format the output for nice TAP. +\pset format unaligned +\pset tuples_only true +\pset pager + +-- Revert all changes on failure. +\set ON_ERROR_ROLLBACK 1 +\set ON_ERROR_STOP true +\set QUIET 1 + +-- Load the TAP functions. +BEGIN; + +-- Plan the tests. +SELECT plan(1); + +-- ensures the column exists and seed data has been updated. +SELECT cmp_ok( + COUNT(*)::int, '>=', 3, + 'At least 3 copy status should be configured as "checkout_ok"') + FROM config.copy_status WHERE checkout_ok; + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; -- 2.11.0