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/040-empire/010-create-empire.sql
Emmanuel BENOîT 56eddcc4f0 Game updates improvements
* Added a set of tables which define game updates and their targets.
These definitions replace the old enumerate type. Added a set of
triggers which automatically create specific update tables, insert
missing entries, etc... when game update types are being manipulated.

* Removed manual insertion of game updates from empire creation
function and universe generator.

* Added registration of core update targets (i.e. planets and empires),
updated all existing game update processing functions and added type
registrations

* Created Maven project for game updates control components, moved
existing components from the -simple project, rewritten most of what
they contained, added new components for server-side update batch
processing
2012-02-03 16:25:03 +01:00

61 lines
No EOL
2.1 KiB
PL/PgSQL

/*
* Test the emp.create_empire() function
*/
BEGIN;
/* We need a pair of natural resources, a basic resource, a planet
* and an empire name.
*/
\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 , 'natRes' );
SELECT _create_resources( 1 , 'basicRes' );
SELECT _create_raw_planets( 1 , 'testPlanet' );
SELECT _create_emp_names( 1 , 'testEmp' );
/***** TESTS BEGIN HERE *****/
SELECT plan( 7 );
SELECT emp.create_empire( _get_emp_name( 'testEmp1' ) ,
_get_map_name( 'testPlanet1' ) ,
200.0 );
SELECT diag_test_name( 'emp.create_empire() - Empire exists' );
SELECT is( COUNT(*)::INT , 1 ) FROM emp.empires
WHERE name_id = _get_emp_name( 'testEmp1' );
SELECT diag_test_name( 'emp.create_empire() - Empire cash' );
SELECT is( cash , 200.0::REAL ) FROM emp.empires
WHERE name_id = _get_emp_name( 'testEmp1' );
SELECT diag_test_name( 'emp.create_empire() - Empire debt' );
SELECT is( debt , 0.0::REAL ) FROM emp.empires
WHERE name_id = _get_emp_name( 'testEmp1' );
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings include all natural resources' );
SELECT is( COUNT(*)::INT , 2 )
FROM defs.natural_resources
INNER JOIN emp.mining_settings
USING ( resource_name_id )
WHERE empire_id = _get_emp_name( 'testEmp1' );
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings do not include basic resources' );
SELECT is( COUNT(*)::INT , 2 )
FROM defs.resources
INNER JOIN emp.mining_settings
USING ( resource_name_id )
WHERE empire_id = _get_emp_name( 'testEmp1' );
SELECT diag_test_name( 'emp.create_empire() - Empire mining settings are all set to 2' );
SELECT is( COUNT( * )::INT , 0 )
FROM emp.mining_settings
WHERE empire_id = _get_emp_name( 'testEmp1' )
AND empmset_weight <> 2;
SELECT diag_test_name( 'emp.create_empire() - Empire resources have been initialised' );
SELECT is( COUNT(*)::INT , 3 )
FROM emp.resources
WHERE empire_id = _get_emp_name( 'testEmp1' );
SELECT * FROM finish( );
ROLLBACK;