Emmanuel BENOîT
afc66166e0
* Changed the way mining settings work: use a priority value (between 0 and 4) as the weight. Leaving them as they were before would have caused numerous problems (and a lot of unnecessary code to work around them) * Empire mining settings will be created along with the empire's own record. By default all natural resources will have weight = 2. * Added a set of four stored procedures which can be used to update an empire's mining settings, including planet-specific settings. The emp.mset_update_start() function can be used to start an update (on an empire's settings if there is only one parameter, or on a planet's settings if there are two parameters); the emp.mset_update_set() and emp.mset_update_apply() functions are then used to modify the settings and apply the changes, respectively.
74 lines
No EOL
3.7 KiB
PL/PgSQL
74 lines
No EOL
3.7 KiB
PL/PgSQL
/*
|
|
* Test the emp.mset_update_start( INT , INT ) function
|
|
*/
|
|
BEGIN;
|
|
/* We need a pair of natural resources, an empire, a pair of planets with
|
|
* resource providers. The empire must own one of the planets.
|
|
*/
|
|
\i utils/strings.sql
|
|
\i utils/resources.sql
|
|
\i utils/accounts.sql
|
|
\i utils/naming.sql
|
|
\i utils/universe.sql
|
|
SELECT _create_natural_resources( 2 , 'testResource' );
|
|
SELECT _create_raw_planets( 3 , 'testPlanet' );
|
|
SELECT _create_emp_names( 1 , 'testEmp' );
|
|
SELECT emp.create_empire( _get_emp_name( 'testEmp1' ) ,
|
|
_get_map_name( 'testPlanet1' ) ,
|
|
200.0 );
|
|
SELECT _create_resource_provider( 'testPlanet1' , 'testResource1' );
|
|
SELECT _create_resource_provider( 'testPlanet2' , 'testResource1' );
|
|
INSERT INTO emp.planets ( empire_id , planet_id )
|
|
VALUES ( _get_emp_name( 'testEmp1' ) , _get_map_name( 'testPlanet3' ) );
|
|
|
|
/***** TESTS BEGIN HERE *****/
|
|
SELECT plan( 14 );
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on bad empire identifier' );
|
|
SELECT ok( NOT emp.mset_update_start( _get_bad_emp_name( ) , _get_map_name( 'testPlanet1' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists despite bad empire identifier' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE mset_update;
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on bad planet identifier' );
|
|
SELECT ok( NOT emp.mset_update_start( _get_emp_name( 'testEmp1' ) , _get_bad_map_name( ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists despite bad planet identifier' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE mset_update;
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on unowned planet identifier' );
|
|
SELECT ok( NOT emp.mset_update_start( _get_emp_name( 'testEmp1' ) , _get_map_name( 'testPlanet2' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists despite unowned planet identifier' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE mset_update;
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on unowned planet identifier' );
|
|
SELECT ok( NOT emp.mset_update_start( _get_emp_name( 'testEmp1' ) , _get_map_name( 'testPlanet2' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists despite unowned planet identifier' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE mset_update;
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on planet with no resource providers' );
|
|
SELECT ok( NOT emp.mset_update_start( _get_emp_name( 'testEmp1' ) , _get_map_name( 'testPlanet3' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists despite planet with no resource providers' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE mset_update;
|
|
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on valid identifiers' );
|
|
SELECT ok( emp.mset_update_start( _get_emp_name( 'testEmp1' ) , _get_map_name( 'testPlanet1' ) ) );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table exists' );
|
|
SELECT has_table( 'mset_update' );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table contains all required entries' );
|
|
SELECT is( COUNT(*)::INT , 1 )
|
|
FROM mset_update
|
|
WHERE empire_id = _get_emp_name( 'testEmp1' )
|
|
AND planet_id = _get_map_name( 'testPlanet1' );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Temporary table does not contain extra entries' );
|
|
SELECT is( COUNT(*)::INT , 0 )
|
|
FROM mset_update
|
|
WHERE empire_id <> _get_emp_name( 'testEmp1' )
|
|
OR planet_id <> _get_map_name( 'testPlanet1' );
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |