Emmanuel BENOîT
e64f847ec3
* Modified owned planet view to include a field which indicates whether mining settings are specific to the planet or come from the empire; modified "simple" game components accordingly * Modified stored procedures to only allow planet-specific mining settings updates when the planet actually uses planet-specific settings, and added a stored procedure which toggles the source of a planet's settings * Added corresponding parts to mining settings DAO and resources controller * Added session commands and server command handlers that toggle the source of the settings and that upload the settings * Split planet page template into multiple files for clarity and added the mining priorities form to the natural resources tab
84 lines
No EOL
4.4 KiB
PL/PgSQL
84 lines
No EOL
4.4 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( 16 );
|
|
|
|
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 IF EXISTS 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 IF EXISTS 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 IF EXISTS 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 IF EXISTS 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 IF EXISTS mset_update;
|
|
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on valid identifiers but no existing settings' );
|
|
SELECT ok( NOT 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 despite lack of settings' );
|
|
SELECT has_table( 'mset_update' );
|
|
DROP TABLE IF EXISTS mset_update;
|
|
|
|
INSERT INTO emp.planet_mining_settings( empire_id , planet_id , resource_name_id )
|
|
SELECT _get_emp_name( 'testEmp1' ) , planet_id , resource_name_id
|
|
FROM verse.resource_providers
|
|
WHERE planet_id = _get_map_name( 'testPlanet1' );
|
|
SELECT diag_test_name( 'emp.mset_update_start( INT , INT ) - Return value on valid identifiers and existing settings' );
|
|
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; |