Emmanuel BENOîT
afc66166e0
* Changed the way mining settings work: use a priority value (between 0 and 4) as the weight. Leaving them as they were before would have caused numerous problems (and a lot of unnecessary code to work around them) * Empire mining settings will be created along with the empire's own record. By default all natural resources will have weight = 2. * Added a set of four stored procedures which can be used to update an empire's mining settings, including planet-specific settings. The emp.mset_update_start() function can be used to start an update (on an empire's settings if there is only one parameter, or on a planet's settings if there are two parameters); the emp.mset_update_set() and emp.mset_update_apply() functions are then used to modify the settings and apply the changes, respectively.
37 lines
No EOL
1.5 KiB
PL/PgSQL
37 lines
No EOL
1.5 KiB
PL/PgSQL
/*
|
|
* Test the emp.mset_update_set() function
|
|
*/
|
|
BEGIN;
|
|
CREATE TEMPORARY TABLE mset_update(
|
|
empire_id INT ,
|
|
resource_name_id INT ,
|
|
empmset_weight INT
|
|
) ON COMMIT DROP;
|
|
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
|
|
|
|
/***** TESTS BEGIN HERE *****/
|
|
SELECT plan( 7 );
|
|
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update' );
|
|
SELECT ok( emp.mset_update_set( 1 , 1 ) );
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update results (1/2)' );
|
|
SELECT is( empmset_weight , 1 ) FROM mset_update WHERE resource_name_id = 1;
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update results (2/2)' );
|
|
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 2;
|
|
DELETE FROM mset_update;
|
|
|
|
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Update on unknown resource' );
|
|
SELECT ok( NOT emp.mset_update_set( 12 , 1 ) );
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Unknown resource update results (1/2)' );
|
|
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 1;
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Unknown resource update results (2/2)' );
|
|
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 2;
|
|
DELETE FROM mset_update;
|
|
|
|
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
|
|
SELECT diag_test_name( 'emp.mset_update_set( ) - Update with invalid weight' );
|
|
SELECT ok( emp.mset_update_set( 1 , -1 ) );
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |