Emmanuel BENOîT
b49bc1a44f
* Added missing table that should store a planet's resources data (income and upkeep for each type of resource). * Modified resource definition functions and universe generator to initialise planet resource records as well * Heavy clean-up in resource definition function unit tests
46 lines
No EOL
1.3 KiB
PL/PgSQL
46 lines
No EOL
1.3 KiB
PL/PgSQL
/*
|
|
* Test the defs.uoc_resource() functions
|
|
*/
|
|
BEGIN;
|
|
/* Create a fake internal function that will just push its parameters to
|
|
* a temporary table.
|
|
*/
|
|
CREATE TEMPORARY TABLE calls_to_internal(
|
|
name TEXT , description TEXT , category TEXT , weight INT
|
|
) ON COMMIT DROP;
|
|
CREATE OR REPLACE FUNCTION defs.uoc_resource_internal(
|
|
_name TEXT ,
|
|
_description TEXT ,
|
|
_category TEXT ,
|
|
_weight INT )
|
|
RETURNS defs.resource_update_result
|
|
CALLED ON NULL INPUT
|
|
VOLATILE
|
|
SECURITY INVOKER
|
|
AS $$
|
|
INSERT INTO calls_to_internal VALUES (
|
|
$1 , $2 , CASE WHEN $3 IS NULL THEN 'NULL' ELSE $3 END , $4
|
|
);
|
|
SELECT 'BAD_STRINGS'::defs.resource_update_result;
|
|
$$ LANGUAGE SQL;
|
|
|
|
/****** TESTS BEGIN HERE ******/
|
|
SELECT plan( 2 );
|
|
|
|
SELECT diag_test_name( 'defs.uoc_resource() - Calls internal function (without category)' );
|
|
SELECT defs.uoc_resource( 'a' , 'b' , 1 );
|
|
SELECT set_eq(
|
|
$$ SELECT * FROM calls_to_internal; $$ ,
|
|
$$ VALUES( 'a' , 'b' , 'NULL' , 1 ) $$
|
|
);
|
|
DELETE FROM calls_to_internal;
|
|
|
|
SELECT diag_test_name( 'defs.uoc_resource() - Calls internal function (without category)' );
|
|
SELECT defs.uoc_resource( 'a' , 'b' , 'c' , 1 );
|
|
SELECT set_eq(
|
|
$$ SELECT * FROM calls_to_internal; $$ ,
|
|
$$ VALUES( 'a' , 'b' , 'c' , 1 ) $$
|
|
);
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |