2012-01-18 09:28:35 +01:00
|
|
|
/*
|
|
|
|
* Tests for bugs.dump_planet_resources_view
|
|
|
|
*/
|
|
|
|
BEGIN;
|
|
|
|
/*
|
2012-01-19 10:28:12 +01:00
|
|
|
* We need a couple of resources (one natural, one basic), four planets
|
|
|
|
* with valid planet resource records (three of the planets will have a
|
|
|
|
* resource provider and one of them will have planet-specific mining
|
|
|
|
* settings), three empires (owning a planet without resource provider,
|
|
|
|
* with resource provider and with resource provider and mining settings,
|
|
|
|
* respectively).
|
2012-01-18 09:28:35 +01:00
|
|
|
*/
|
|
|
|
\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' );
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT _create_raw_planets( 4 , 'planet' );
|
2012-01-18 09:28:35 +01:00
|
|
|
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
|
2012-01-19 10:28:12 +01:00
|
|
|
) , (
|
|
|
|
_get_map_name( 'planet4' ) , _get_string( 'basicRes1' ) , 13 , 14
|
|
|
|
) , (
|
|
|
|
_get_map_name( 'planet4' ) , _get_string( 'natRes1' ) , 15 , 16
|
2012-01-18 09:28:35 +01:00
|
|
|
);
|
|
|
|
SELECT _create_resource_provider( 'planet1' , 'natRes1' );
|
|
|
|
SELECT _create_resource_provider( 'planet3' , 'natRes1' );
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT _create_resource_provider( 'planet4' , 'natRes1' );
|
2012-01-18 09:28:35 +01:00
|
|
|
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT _create_emp_names( 3 , 'empire' );
|
2012-01-18 09:28:35 +01:00
|
|
|
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 );
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT emp.create_empire( _get_emp_name( 'empire3' ) ,
|
|
|
|
_get_map_name( 'planet4' ) ,
|
|
|
|
200.0 );
|
|
|
|
|
|
|
|
INSERT INTO emp.planet_mining_settings(
|
|
|
|
empire_id , planet_id , resource_name_id , emppmset_weight
|
|
|
|
) VALUES (
|
|
|
|
_get_emp_name( 'empire3' ) , _get_map_name( 'planet4' ) ,
|
|
|
|
_get_string( 'natRes1' ) , 2
|
|
|
|
);
|
2012-01-18 09:28:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***** TESTS BEGIN HERE *****/
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT plan( 3 );
|
2012-01-18 09:28:35 +01:00
|
|
|
|
|
|
|
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
|
2012-01-19 10:28:12 +01:00
|
|
|
) , (
|
|
|
|
_get_emp_name( 'empire3' ) , _get_map_name( 'planet4' ) , 'basicRes1' , 13 , 14
|
2012-01-18 09:28:35 +01:00
|
|
|
) $$ );
|
|
|
|
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records with resource providers, no settings' );
|
2012-01-18 09:28:35 +01:00
|
|
|
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
|
2012-01-19 10:28:12 +01:00
|
|
|
AND mining_priority IS NULL
|
2012-01-18 09:28:35 +01:00
|
|
|
$$ , $$ VALUES (
|
|
|
|
_get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 'natRes1' , 3 , 4
|
|
|
|
) $$ );
|
|
|
|
|
2012-01-19 10:28:12 +01:00
|
|
|
SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records with resource providers and settings' );
|
|
|
|
SELECT set_eq( $$
|
|
|
|
SELECT empire_id , planet_id , resource_name , pres_income ,
|
|
|
|
pres_upkeep , mining_priority
|
|
|
|
FROM bugs.dump_planet_resources_view
|
|
|
|
WHERE resprov_quantity IS NOT NULL
|
|
|
|
AND mining_priority IS NOT NULL
|
|
|
|
$$ , $$ VALUES (
|
|
|
|
_get_emp_name( 'empire3' ) , _get_map_name( 'planet4' ) , 'natRes1' , 15 , 16 , 2
|
|
|
|
) $$ );
|
|
|
|
|
2012-01-18 09:28:35 +01:00
|
|
|
SELECT * FROM finish( );
|
|
|
|
ROLLBACK;
|