Emmanuel BENOîT
74b6f2ab09
* 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)
35 lines
No EOL
844 B
PL/PgSQL
35 lines
No EOL
844 B
PL/PgSQL
/*
|
|
* Test sys.gu_pmc_totals_view
|
|
*/
|
|
BEGIN;
|
|
/* Create a table which will server as an alternate source for
|
|
* sys.gu_pmc_weights_view ; the table is not temporary (PostgreSQL
|
|
* won't allow replacing the view otherwise), but will be dropped
|
|
* on rollback anyway.
|
|
*/
|
|
CREATE TABLE fake_mining_weights(
|
|
planet_id INT ,
|
|
resource_name_id INT ,
|
|
pmc_weight DOUBLE PRECISION
|
|
);
|
|
|
|
CREATE OR REPLACE VIEW sys.gu_pmc_weights_view
|
|
AS SELECT * FROM fake_mining_weights;
|
|
|
|
/* Insert fake records for two different planets */
|
|
INSERT INTO fake_mining_weights VALUES
|
|
( 1 , 0 , 1 ) ,
|
|
( 1 , 1 , 2 ) ,
|
|
( 2 , 0 , 4 ) ,
|
|
( 2 , 1 , 5 );
|
|
|
|
/***** TESTS BEGIN HERE *****/
|
|
SELECT plan( 1 );
|
|
|
|
SELECT set_eq(
|
|
$$ SELECT * FROM sys.gu_pmc_totals_view $$ ,
|
|
$$ VALUES ( 1 , 3.0 ) , ( 2 , 9.0 ) $$
|
|
);
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |