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

35 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

/*
* 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;