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/dirty/010-mining-update-locks/run-test.sql
Emmanuel BENOîT 74b6f2ab09 Mining computation update
* Added various views and helper functions used by the mining
computation but which may be re-used in other parts.

* Added mining computation update type and associated update function

* New constants: game.resources.weightBase (the value used to compute
weights from mining settings) and game.resources.extraction (the
quantity extracted in a day from a full provider at difficulty 0)
2012-01-16 12:35:20 +01:00

104 lines
No EOL
4.2 KiB
PL/PgSQL

/*
* Test the locks set by sys.gu_pmc_get_data( )
*/
BEGIN;
SELECT * FROM sys.gu_pmc_get_data( 0 );
SELECT plan( 7 );
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on planets' );
SELECT set_eq ( $$
SELECT name_id , shared , exclusive
FROM verse.planets pl
INNER JOIN ( SELECT * FROM _get_locks_on( 'verse.planets' ) ) p
ON p.ctid = pl.ctid;
$$ , $$
VALUES ( _get_map_name( 'planet2' ) , TRUE , FALSE ) ,
( _get_map_name( 'planet3' ) , TRUE , FALSE ) ,
( _get_map_name( 'planet4' ) , TRUE , FALSE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on resource providers' );
SELECT set_eq ( $$
SELECT planet_id , resource_name_id , shared , exclusive
FROM verse.resource_providers rp
INNER JOIN ( SELECT * FROM _get_locks_on( 'verse.resource_providers' ) ) p
ON p.ctid = rp.ctid;
$$ , $$
VALUES ( _get_map_name( 'planet2' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet2' ) , _get_string('resource2') , FALSE , TRUE ) ,
( _get_map_name( 'planet3' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet3' ) , _get_string('resource2') , FALSE , TRUE ) ,
( _get_map_name( 'planet4' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet4' ) , _get_string('resource2') , FALSE , TRUE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on planet resources' );
SELECT set_eq ( $$
SELECT planet_id , resource_name_id , shared , exclusive
FROM verse.planet_resources pr
INNER JOIN ( SELECT * FROM _get_locks_on( 'verse.planet_resources' ) ) p
ON p.ctid = pr.ctid;
$$ , $$
VALUES ( _get_map_name( 'planet2' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet2' ) , _get_string('resource2') , FALSE , TRUE ) ,
( _get_map_name( 'planet3' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet3' ) , _get_string('resource2') , FALSE , TRUE ) ,
( _get_map_name( 'planet4' ) , _get_string('resource1') , FALSE , TRUE ) ,
( _get_map_name( 'planet4' ) , _get_string('resource2') , FALSE , TRUE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on empire planets' );
SELECT set_eq ( $$
SELECT planet_id , empire_id , shared , exclusive
FROM emp.planets ep
INNER JOIN ( SELECT * FROM _get_locks_on( 'emp.planets' ) ) p
ON p.ctid = ep.ctid;
$$ , $$
VALUES ( _get_map_name( 'planet3' ) , _get_emp_name('empire1' ) , TRUE , FALSE ) ,
( _get_map_name( 'planet4' ) , _get_emp_name('empire2' ) , TRUE , FALSE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on mining settings' );
SELECT set_eq ( $$
SELECT empire_id , resource_name_id , shared , exclusive
FROM emp.mining_settings ms
INNER JOIN ( SELECT * FROM _get_locks_on( 'emp.mining_settings' ) ) p
ON p.ctid = ms.ctid;
$$ , $$
VALUES ( _get_emp_name('empire1' ) , _get_string( 'resource1' ) , TRUE , FALSE ) ,
( _get_emp_name('empire1' ) , _get_string( 'resource2' ) , TRUE , FALSE ) ,
( _get_emp_name('empire2' ) , _get_string( 'resource1' ) , TRUE , FALSE ) ,
( _get_emp_name('empire2' ) , _get_string( 'resource2' ) , TRUE , FALSE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on planet mining settings' );
SELECT set_eq ( $$
SELECT empire_id , planet_id , resource_name_id , shared , exclusive
FROM emp.planet_mining_settings ms
INNER JOIN ( SELECT * FROM _get_locks_on( 'emp.planet_mining_settings' ) ) p
ON p.ctid = ms.ctid;
$$ , $$
VALUES ( _get_emp_name('empire2' ) , _get_map_name( 'planet4' ) , _get_string( 'resource1' ) , TRUE , FALSE ) ,
( _get_emp_name('empire2' ) , _get_map_name( 'planet4' ) , _get_string( 'resource2' ) , TRUE , FALSE );
$$
);
SELECT diag_test_name( 'sys.gu_pmc_get_data() - Locks on planet happiness records' );
SELECT set_eq ( $$
SELECT planet_id , shared , exclusive
FROM verse.planet_happiness pl
INNER JOIN ( SELECT * FROM _get_locks_on( 'verse.planet_happiness' ) ) p
ON p.ctid = pl.ctid;
$$ , $$
VALUES ( _get_map_name( 'planet3' ) , TRUE , FALSE ) ,
( _get_map_name( 'planet4' ) , TRUE , FALSE );
$$
);
SELECT * FROM finish( );
ROLLBACK;