Database management changes
* Added in-base logging through a foreign data wrapper, which is only possible using PostgreSQL 9.1 * Renamed database-related configuration files to indicate that they are samples, and added the "real" names to the Git ignore list. Server distribution modified accordingly. * Removed PL/PgSQL registration (it was only necessary on 8.4) * Added pgTAP SQL definitions and a script which will (hopefully) be executed by the build system after the main Java build in order to execute database unit tests. The script supports both admin- and user- level testing. I also added a few tests to make sure the testing framework actually runs them. * Added documentation about the database definitions structure
This commit is contained in:
parent
f682594cbd
commit
be3106c463
18 changed files with 7669 additions and 47 deletions
7402
legacyworlds-server-data/db-structure/tests/pgtap.sql
Normal file
7402
legacyworlds-server-data/db-structure/tests/pgtap.sql
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,39 @@
|
|||
BEGIN;
|
||||
SELECT plan( 3 );
|
||||
|
||||
--
|
||||
-- Insertion through sys.write_log()
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION _test_this( )
|
||||
RETURNS BIGINT
|
||||
AS $$
|
||||
SELECT sys.write_log( 'test' , 'WARNING'::log_level , 'test' );
|
||||
$$ LANGUAGE SQL;
|
||||
SELECT lives_ok( 'SELECT _test_this()' );
|
||||
DROP FUNCTION _test_this( );
|
||||
|
||||
--
|
||||
-- Direct insertion must fail
|
||||
--
|
||||
CREATE FUNCTION _test_this( )
|
||||
RETURNS VOID
|
||||
AS $$
|
||||
INSERT INTO sys.logs( component , level , message )
|
||||
VALUES ( 'test' , 'WARNING'::log_level , 'test' );
|
||||
$$ LANGUAGE SQL;
|
||||
SELECT throws_ok( 'SELECT _test_this()' , 42501 );
|
||||
DROP FUNCTION _test_this( );
|
||||
|
||||
--
|
||||
-- Updates must fail
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION _test_this( )
|
||||
RETURNS VOID
|
||||
AS $$
|
||||
UPDATE sys.logs SET component = 'random' WHERE component = 'test';
|
||||
$$ LANGUAGE SQL;
|
||||
SELECT throws_ok( 'SELECT _test_this()' , 42501 );
|
||||
DROP FUNCTION _test_this( );
|
||||
|
||||
SELECT * FROM finish( );
|
||||
ROLLBACK;
|
Reference in a new issue