Emmanuel BENOîT
be3106c463
* 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
39 lines
899 B
PL/PgSQL
39 lines
899 B
PL/PgSQL
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;
|