/* * Test the defs.uoc_technology() function when the points for a technology * are updated and empires are researching it. */ BEGIN; \i utils/strings.sql /* * We need a few test strings to play with. Each technology definition * uses four strings (name, category, discovery and description) so we'll * create 4. */ SELECT _create_test_strings( 4 , 's' ); /* Insert one entry. */ INSERT INTO defs.technologies ( technology_name_id , technology_category_id , technology_discovery_id , technology_description_id , technology_price , technology_points ) VALUES ( _get_string( 's1' ) , _get_string( 's2' ) , _get_string( 's3' ) , _get_string( 's4' ) , 1 , 100 ); /* Remove foreign key to empires on empire technologies */ ALTER TABLE emp.technologies_v2 DROP CONSTRAINT fk_emptech_empire; /* Insert records for the new technology, with different states */ INSERT INTO emp.technologies_v2 ( empire_id , technology_name_id , emptech_state , emptech_points , emptech_priority ) VALUES ( 1 , _get_string( 's1' ) , 'RESEARCH' , 50 , 2 ) , ( 2 , _get_string( 's1' ) , 'RESEARCH' , 0 , 2 ); /* Now change the technology so it requires 1000 points */ SELECT defs.uoc_technology( 's1' , 's2' , 's3' , 's4' , 1 , 1000 ); -- ***** TESTS BEGIN HERE ***** SELECT no_plan( ); SELECT diag_test_name( 'defs.uoc_technology() - Update - Scaling of in-progress research' ); SELECT set_eq( $$ SELECT empire_id , ROUND( emptech_points )::INT FROM emp.technologies_v2 WHERE emptech_state = 'RESEARCH' $$ , $$ VALUES( 1 , 500 ) , ( 2 , 0 ) $$ ); SELECT * FROM finish( ); ROLLBACK;