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/050-updates/120-planet-mining/030-gu-pmc-get-data.sql

90 lines
3.2 KiB
MySQL
Raw Normal View History

/*
* 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;