/* * Tests for bugs.dump_planet_resources_view */ BEGIN; /* * We need a couple of resources (one natural, one basic), three planets * with valid planet resource records (two of the planets will have a * resource provider), two empires (owning a planet with and without * resource providers, respectively). */ \i utils/strings.sql \i utils/resources.sql \i utils/accounts.sql \i utils/naming.sql \i utils/universe.sql SELECT _create_natural_resources( 1 , 'natRes' ); SELECT _create_resources( 1 , 'basicRes' ); SELECT _create_raw_planets( 3 , 'planet' ); INSERT INTO verse.planet_resources( planet_id , resource_name_id , pres_income , pres_upkeep ) VALUES ( _get_map_name( 'planet1' ) , _get_string( 'basicRes1' ) , 1 , 2 ) , ( _get_map_name( 'planet1' ) , _get_string( 'natRes1' ) , 3 , 4 ) , ( _get_map_name( 'planet2' ) , _get_string( 'basicRes1' ) , 5 , 6 ) , ( _get_map_name( 'planet2' ) , _get_string( 'natRes1' ) , 7 , 8 ) , ( _get_map_name( 'planet3' ) , _get_string( 'basicRes1' ) , 9 , 10 ) , ( _get_map_name( 'planet3' ) , _get_string( 'natRes1' ) , 11 , 12 ); SELECT _create_resource_provider( 'planet1' , 'natRes1' ); SELECT _create_resource_provider( 'planet3' , 'natRes1' ); SELECT _create_emp_names( 2 , 'empire' ); SELECT emp.create_empire( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 200.0 ); SELECT emp.create_empire( _get_emp_name( 'empire2' ) , _get_map_name( 'planet2' ) , 200.0 ); /***** TESTS BEGIN HERE *****/ SELECT plan( 2 ); SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records without resource providers' ); SELECT set_eq( $$ SELECT empire_id , planet_id , resource_name , pres_income , pres_upkeep FROM bugs.dump_planet_resources_view WHERE resprov_quantity IS NULL $$ , $$ VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 'basicRes1' , 1 , 2 ) , ( _get_emp_name( 'empire2' ) , _get_map_name( 'planet2' ) , 'basicRes1' , 5 , 6 ) , ( _get_emp_name( 'empire2' ) , _get_map_name( 'planet2' ) , 'natRes1' , 7 , 8 ) $$ ); SELECT diag_test_name( 'bugs.dump_planet_resources_view - Records with resource providers' ); SELECT set_eq( $$ SELECT empire_id , planet_id , resource_name , pres_income , pres_upkeep FROM bugs.dump_planet_resources_view WHERE resprov_quantity IS NOT NULL $$ , $$ VALUES ( _get_emp_name( 'empire1' ) , _get_map_name( 'planet1' ) , 'natRes1' , 3 , 4 ) $$ ); SELECT * FROM finish( ); ROLLBACK;