/* * Tests for bugs.dump_emp_resources_view */ BEGIN; /* * We need a basic resource type, a natural resource type, an empire and * the associated resources and mining settings records. */ \i utils/strings.sql \i utils/resources.sql \i utils/accounts.sql \i utils/naming.sql \i utils/universe.sql SELECT _create_resources( 1 , 'resource' ); SELECT _create_natural_resources( 1 , 'natRes' ); SELECT _create_emp_names( 1 , 'empire' ); INSERT INTO emp.empires( name_id , cash ) VALUES ( _get_emp_name( 'empire1' ) , 0 ); INSERT INTO emp.resources( empire_id , resource_name_id , empres_possessed , empres_owed ) VALUES ( _get_emp_name( 'empire1' ) , _get_string( 'resource1' ) , 1 , 2 ) , ( _get_emp_name( 'empire1' ) , _get_string( 'natRes1' ) , 3 , 4 ); INSERT INTO emp.mining_settings ( empire_id , resource_name_id , empmset_weight ) VALUES ( _get_emp_name( 'empire1' ) , _get_string( 'natRes1' ) , 0 ); /***** TESTS BEGIN HERE *****/ SELECT plan( 2 ); SELECT diag_test_name( 'bugs.dump_emp_resources_view - Basic resources' ); SELECT set_eq( $$ SELECT empire_id , resource_name , empres_possessed , empres_owed FROM bugs.dump_emp_resources_view WHERE mining_priority IS NULL $$ , $$ VALUES ( _get_emp_name( 'empire1' ) , 'resource1' , 1 , 2 ) $$ ); SELECT diag_test_name( 'bugs.dump_emp_resources_view - Natural resources' ); SELECT set_eq( $$ SELECT empire_id , resource_name , empres_possessed , empres_owed , mining_priority FROM bugs.dump_emp_resources_view WHERE mining_priority IS NOT NULL $$ , $$ VALUES ( _get_emp_name( 'empire1' ) , 'natRes1' , 3 , 4 , 0 ) $$ ); SELECT * FROM finish( ); ROLLBACK;