These specific ones do not assume stock test data such as the concerto bibs, and
I think such tests should go elsewhere. You need to install pgTAP. I did the
following for my test environment:
git clone git://github.com/theory/pgtap.git
cd pgtap
make
make installcheck
sudo make install
Then in my Evergreen database with psql, I did:
CREATE EXTENSION pgtap;
I also installed a CPAN module to get pg_prove:
sudo cpan TAP::Parser::SourceHandler::pgTAP
You can use psql to run a given test like so:
opensrf@dev141:~/git/Evergreen/Open-ILS/src/sql/Pg/t (pgtap)$ psql -d evergreen -f 0799.state_field_required_toggle.s
1..4
ok 1 - actor.usr_address.state does not have the NOT NULL constraint
ok 2 - ui.patron.edit.au.state.require exists
ok 3 - ui.patron.edit.au.state.show exists
ok 4 - ui.patron.edit.au.state.suggest exists
Or you can use pg_prove on all or some of them:
opensrf@dev141:~/git/Evergreen/Open-ILS/src/sql/Pg/t (pgtap)$ pg_prove -d evergreen *.s
0799.state_field_required_toggle.s .. ok
dewey.s ............................. 1/6
# Failed (TODO) test 6: "testing prefix plus decimal"
# 'YR_DVD_800_100000000000000'
# <
# 'YR_000000000000000_DVD_900'
dewey.s ............................. ok
schema.s ............................ ok
versions.s .......................... ok
All tests successful.
Files=4, Tests=39, 0 wallclock secs ( 0.05 usr 0.03 sys + 0.13 cusr 0.07 csys = 0.28 CPU)
Result: PASS
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
--- /dev/null
+\set ECHO
+\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(4);
+
+-- Run the tests.
+
+SELECT col_is_null(
+ 'actor',
+ 'usr_address',
+ 'state',
+ 'actor.usr_address.state does not have the NOT NULL constraint'
+);
+
+SELECT isnt_empty(
+ 'SELECT * FROM config.org_unit_setting_type WHERE name = $$ui.patron.edit.au.state.require$$',
+ 'ui.patron.edit.au.state.require exists'
+);
+
+SELECT isnt_empty(
+ 'SELECT * FROM config.org_unit_setting_type WHERE name = $$ui.patron.edit.au.state.show$$',
+ 'ui.patron.edit.au.state.show exists'
+);
+
+SELECT isnt_empty(
+ 'SELECT * FROM config.org_unit_setting_type WHERE name = $$ui.patron.edit.au.state.suggest$$',
+ 'ui.patron.edit.au.state.suggest exists'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;
--- /dev/null
+For the tests we put here, let's not assume the stock test data is loaded.
--- /dev/null
+\set ECHO
+\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(6);
+
+-- Run the tests. Converted from Koha's ClassSortRoutine_Dewey.t
+
+SELECT is(
+ asset.label_normalizer_dewey(NULL),
+ '',
+ 'testing whitespace'
+);
+
+SELECT is(
+ asset.label_normalizer_dewey('.... .....'),
+ '',
+ 'testing fullstops'
+);
+
+-- I think these tests below may be looking too deeply into the implementation,
+-- but including them for now
+
+SELECT is(
+ asset.label_normalizer_dewey('123 456'),
+ '123_456000000000000',
+ 'testing numbers'
+);
+
+SELECT is(
+ asset.label_normalizer_dewey('abc123 456'),
+ 'ABC_123_456000000000000',
+ 'testing alphanumeric'
+);
+
+SELECT is(
+ asset.label_normalizer_dewey('ab c123 45 6'),
+ 'AB_C123_45_600000000000000',
+ 'testing middle whitespace'
+);
+
+SELECT todo('Desired behavior in contention. See https://bugs.launchpad.net/evergreen/+bug/1150939', 1);
+
+SELECT cmp_ok(
+ asset.label_normalizer_dewey('YR DVD 800.1'),
+ '<',
+ asset.label_normalizer_dewey('YR DVD 900'),
+ 'testing prefix plus decimal'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;
--- /dev/null
+\set ECHO
+\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(27);
+
+-- Run the tests.
+SELECT has_schema('action','Has action schema');
+SELECT has_schema('action_trigger','Has action_trigger schema');
+SELECT has_schema('actor','Has actor schema');
+SELECT has_schema('acq','Has acq schema');
+SELECT has_schema('asset','Has actor schema');
+SELECT has_schema('auditor','Has auditor schema');
+SELECT has_schema('authority','Has authority schema');
+SELECT has_schema('biblio','Has biblio schema');
+SELECT has_schema('booking','Has booking schema');
+SELECT has_schema('config','Has config schema');
+SELECT has_schema('container','Has container schema');
+SELECT has_schema('evergreen','Has evergreen schema');
+SELECT has_schema('extend_reporter','Has extend_reporter schema');
+SELECT has_schema('metabib','Has metabib schema');
+SELECT has_schema('money','Has money schema');
+SELECT has_schema('offline','Has offline schema');
+SELECT has_schema('permission','Has permission schema');
+SELECT has_schema('public','Has public schema');
+SELECT has_schema('query','Has query schema');
+SELECT has_schema('reporter','Has reporter schema');
+SELECT has_schema('search','Has search schema');
+SELECT has_schema('serial','Has serial schema');
+SELECT has_schema('staging','Has staging schema');
+SELECT has_schema('stats','Has stats schema');
+SELECT has_schema('url_verify','Has url_verify schema');
+SELECT has_schema('vandelay','Has vandelay schema');
+SELECT has_schema('unapi','Has unapi schema');
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;
--- /dev/null
+\set ECHO
+\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(2);
+
+-- Run the tests.
+
+SELECT CASE WHEN pg_version_num() >= 90000
+ THEN pass('Running PostgreSQL 9+')
+ ELSE fail('Not running PostgreSQL 9+')
+END;
+
+SELECT isnt_empty(
+ 'SELECT COUNT(*) FROM config.upgrade_log',
+ 'Have rows in config.upgrade_log'
+);
+
+-- Finish the tests and clean up.
+SELECT * FROM finish();
+ROLLBACK;