This repository has been archived on 2025-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/050-create-resource-providers.sql
Emmanuel BENOîT e50775ec76 Database definition & tests organisation
* The main loader script has been updated to generate the list of files
it needs to load automatically. As a consequence, files that contained
manually-maintained lists of scripts have been removed, and definition
directories have been renamed accordingly.

* PostgreSQL extension loading and configuration has been moved to a
separate script to be loaded automatically in the main transaction.

* Data and function definition scripts that had the -data or -functions
suffix have been renamed (the suffix is unnecessary).

* Unit tests have been reorganised to follow the definition's structure.

* Documentation has been improved
2012-01-06 11:19:19 +01:00

35 lines
No EOL
1.1 KiB
PL/PgSQL

/*
* Test the "main" verse.create_resource_providers( ) function
*/
BEGIN;
/* Create a dummy rp_stats table that contains a few identifiers */
CREATE TEMP TABLE rp_stats
OF verse.resprov_generator_type
ON COMMIT DROP;
INSERT INTO rp_stats ( resource_name_id )
VALUES ( 1 ) , ( 2 ) , ( 3 ) , ( 4 );
/* Replace the verse.create_resource_providers( area , type ) function
* with a function that deletes the resource type it was given from
* rp_stats.
*/
CREATE OR REPLACE FUNCTION verse.create_resource_providers(
_area verse.generator_area_type ,
_data verse.resprov_generator_type )
RETURNS VOID
STRICT VOLATILE
SECURITY INVOKER
AS $create_resource_providers$
BEGIN
DELETE FROM rp_stats WHERE resource_name_id = _data.resource_name_id;
END;
$create_resource_providers$ LANGUAGE PLPGSQL;
SELECT plan(1);
SELECT diag_test_name( 'verse.create_resource_providers( area ) - Calls to per-type function' );
SELECT verse.create_resource_providers( ROW( 0 , 0 , 1 , 1 ) );
SELECT is( COUNT(*)::INT , 0 ) FROM rp_stats;
SELECT * FROM finish( );
ROLLBACK;