Emmanuel BENOîT
bf6bea5a79
* The quantities of resources extracted from mines will now be updated as soon as they have a reason to. This includes planet assignment, abandonment, ownership changes, and updates to mining priorities. * The mining update will now remove the current resource income from the providers, and only then re-compute all extracted quantities. This is more logical and corresponds to the way the other game updates work. * Fixed bug in extraction computation where the size of the planet's happy population was used instead of the happy/total ratio when adjusting the mining production for riots. * The following SQL scripts must be re-executed to upgrade a database: -> 040-functions/040-empire.sql -> 040-functions/145-resource-providers.sql -> 040-functions/147-empire-mining.sql -> 050-updates/120-planet-mining.sql
89 lines
3.2 KiB
PL/PgSQL
89 lines
3.2 KiB
PL/PgSQL
/*
|
|
* Test the sys.gu_pmc_get_data() function
|
|
*/
|
|
BEGIN;
|
|
\i utils/common-setup/setup-gu-pmc-get-data-test.sql
|
|
|
|
/* Select results into a temporary table */
|
|
CREATE TEMPORARY TABLE test_results
|
|
AS SELECT * FROM sys.gu_pmc_get_data( 0 );
|
|
|
|
|
|
|
|
/***** TESTS BEGIN HERE *****/
|
|
SELECT plan( 9 );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Neutral planet without resource providers not included' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet1' );
|
|
$$ );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Neutral planet with resource providers - Rows included' );
|
|
SELECT is( COUNT(*)::INT , 2)
|
|
FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet2' )
|
|
AND difficulty = 0.2 AND empire IS NULL
|
|
AND happiness IS NULL AND weight IS NULL
|
|
AND total_weight IS NULL;
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Neutral planet with resource providers - No extra rows' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet2' )
|
|
AND NOT ( difficulty = 0.2 AND empire IS NULL
|
|
AND happiness IS NULL AND weight IS NULL
|
|
AND total_weight IS NULL );
|
|
$$ );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Planet using empire settings - Rows included' );
|
|
SELECT is( COUNT(*)::INT , 2)
|
|
FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet3' ) AND difficulty = 0.3
|
|
AND empire = _get_emp_name( 'empire1' )
|
|
AND happiness IS NOT NULL AND weight = 100
|
|
AND total_weight = 200;
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Planet using empire settings - No extra rows' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet3' )
|
|
AND NOT ( difficulty = 0.3
|
|
AND empire = _get_emp_name( 'empire1' )
|
|
AND happiness IS NOT NULL
|
|
AND weight = 100 AND total_weight = 200 );
|
|
$$ );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Planet using specific settings - Rows included' );
|
|
SELECT is( COUNT(*)::INT , 2)
|
|
FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet4' ) AND difficulty = 0.4
|
|
AND empire = _get_emp_name( 'empire2' )
|
|
AND happiness IS NOT NULL AND (
|
|
( resource = _get_string( 'resource1' ) AND weight = 10 )
|
|
OR ( resource = _get_string( 'resource2' ) AND weight = 1000 ) )
|
|
AND total_weight = 1010;
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Planet using specific settings - No extra rows' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet4' )
|
|
AND NOT ( difficulty = 0.4
|
|
AND empire = _get_emp_name( 'empire2' )
|
|
AND happiness IS NOT NULL
|
|
AND total_weight = 1010 AND (
|
|
( resource = _get_string( 'resource1' ) AND weight = 10 )
|
|
OR ( resource = _get_string( 'resource2' ) AND weight = 1000 ) ) );
|
|
$$ );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Owned planet without resource providers not included' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet5' );
|
|
$$ );
|
|
|
|
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Planet matching all criterias but marked as processed not included' );
|
|
SELECT is_empty( $$
|
|
SELECT * FROM test_results
|
|
WHERE planet = _get_map_name ( 'planet6' );
|
|
$$ );
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK;
|