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/145-resource-providers/090-emp-mining-get-input.sql

69 lines
2.9 KiB
MySQL
Raw Normal View History

/*
* Tests for the emp.mining_get_input() function
*/
BEGIN;
\i utils/common-setup/setup-gu-pmc-get-data-test.sql
SELECT plan( 7 );
CREATE TEMPORARY TABLE test_results
AS SELECT * FROM emp.mining_get_input( _get_emp_name( 'empire1' ) );
SELECT diag_test_name( 'emp.mining_get_input() - Empire with a 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( 'emp.mining_get_input() - Empire with a planet using empire settings - No extra rows' );
SELECT is_empty( $$
SELECT * FROM test_results
WHERE NOT ( 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 );
$$ );
DROP TABLE test_results;
CREATE TEMPORARY TABLE test_results
AS SELECT * FROM emp.mining_get_input( _get_emp_name( 'empire2' ) );
SELECT diag_test_name( 'emp.mining_get_input() - Empire with a 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( 'emp.mining_get_input() - Empire with a planet using specific settings - No extra rows' );
SELECT is_empty( $$
SELECT * FROM test_results
WHERE NOT ( planet = _get_map_name ( 'planet4' )
AND 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 ) ) );
$$ );
DROP TABLE test_results;
SELECT diag_test_name( 'emp.mining_get_input() - Owned planet without resource providers -> no rows' );
SELECT is_empty( $$ SELECT * FROM emp.mining_get_input( _get_emp_name( 'empire3' ) ) $$ );
CREATE TEMPORARY TABLE test_results
AS SELECT * FROM emp.mining_get_input( _get_emp_name( 'empire4' ) );
SELECT diag_test_name( 'emp.mining_get_input() - Selects planets independently of update state' );
SELECT is( COUNT(*)::INT , 2)
FROM test_results
WHERE planet = _get_map_name ( 'planet6' ) AND difficulty = 0.6
AND empire = _get_emp_name( 'empire4' )
AND happiness IS NOT NULL AND weight = 100
AND total_weight = 200;
DROP TABLE test_results;
SELECT diag_test_name( 'emp.mining_get_input() - Empire with no planets -> no rows' );
SELECT is_empty( $$ SELECT * FROM emp.mining_get_input( _get_emp_name( 'empire5' ) ) $$ );
SELECT * FROM finish( );
ROLLBACK;