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/200-bugs/010-dump-planet-resources-view.sql
Emmanuel BENOîT ce6d86d344 Planet resources and resource providers in XML dumps
* Dump version bumped up to 2

* Added SQL view that shows resource delta and provider information for
all empire-owned planets

* Added new storage classes for resource providers and resource deltas

* Added row mapper which extracts all planet resources information
(providers and deltas)

* Modified dump generator to include planet resources / resource
providers
2012-01-18 09:28:35 +01:00

73 lines
No EOL
2.4 KiB
PL/PgSQL

/*
* Tests for bugs.dump_planet_resources_view
*/
BEGIN;
/*
* We need a couple of resources (one natural, one basic), three planets
* with valid planet resource records (two of the planets will have a
* resource provider), two empires (owning a planet with and without
* resource providers, respectively).
*/
\i utils/strings.sql
\i utils/resources.sql
\i utils/accounts.sql
\i utils/naming.sql
\i utils/universe.sql
SELECT _create_natural_resources( 1 , 'natRes' );
SELECT _create_resources( 1 , 'basicRes' );
SELECT _create_raw_planets( 3 , 'planet' );
INSERT INTO verse.planet_resources(
planet_id , resource_name_id , pres_income , pres_upkeep
) VALUES (
_get_map_name( 'planet1' ) , _get_string( 'basicRes1' ) , 1 , 2
) , (
_get_map_name( 'planet1' ) , _get_string( 'natRes1' ) , 3 , 4
) , (
_get_map_name( 'planet2' ) , _get_string( 'basicRes1' ) , 5 , 6
) , (
_get_map_name( 'planet2' ) , _get_string( 'natRes1' ) , 7 , 8
) , (
_get_map_name( 'planet3' ) , _get_string( 'basicRes1' ) , 9 , 10
) , (
_get_map_name( 'planet3' ) , _get_string( 'natRes1' ) , 11 , 12
);
SELECT _create_resource_provider( 'planet1' , 'natRes1' );
SELECT _create_resource_provider( 'planet3' , 'natRes1' );
SELECT _create_emp_names( 2 , 'empire' );
SELECT emp.create_empire( _get_emp_name( 'empire1' ) ,
_get_map_name( 'planet1' ) ,
200.0 );
SELECT emp.create_empire( _get_emp_name( 'empire2' ) ,
_get_map_name( 'planet2' ) ,
200.0 );
/***** TESTS BEGIN HERE *****/
SELECT plan( 2 );
SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records without resource providers' );
SELECT set_eq( $$
SELECT empire_id , planet_id , resource_name , pres_income , pres_upkeep
FROM bugs.dump_planet_resources_view
WHERE resprov_quantity IS NULL
$$ , $$ VALUES (
_get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 'basicRes1' , 1 , 2
) , (
_get_emp_name( 'empire2' ) , _get_map_name( 'planet2' ) , 'basicRes1' , 5 , 6
) , (
_get_emp_name( 'empire2' ) , _get_map_name( 'planet2' ) , 'natRes1' , 7 , 8
) $$ );
SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records with resource providers' );
SELECT set_eq( $$
SELECT empire_id , planet_id , resource_name , pres_income , pres_upkeep
FROM bugs.dump_planet_resources_view
WHERE resprov_quantity IS NOT NULL
$$ , $$ VALUES (
_get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 'natRes1' , 3 , 4
) $$ );
SELECT * FROM finish( );
ROLLBACK;