/*
* Test emp.scaled_mining_weights_view
*/
BEGIN;
/* Create a table which will server as an alternate source for
* emp.mining_settings_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_settings(
planet_id INT ,
resource_name_id INT ,
mset_weight INT ,
mset_specific BOOLEAN
);
CREATE OR REPLACE VIEW emp.mining_settings_view
AS SELECT * FROM fake_mining_settings;
/* Insert fake records for each possible mining setting */
INSERT INTO fake_mining_settings VALUES
( 1 , 0 , 0 , FALSE ) ,
( 1 , 1 , 1 , FALSE ) ,
( 1 , 2 , 2 , FALSE ) ,
( 1 , 3 , 3 , FALSE ) ,
( 1 , 4 , 4 , FALSE );
/***** TESTS BEGIN HERE *****/
SELECT plan( 2 );
SELECT diag_test_name( 'emp.scaled_mining_weights_view - Rows present' );
SELECT isnt( COUNT(*)::INT , 0 )
FROM emp.scaled_mining_weights_view;
SELECT diag_test_name( 'emp.scaled_mining_weights_view - weight = game.resources.weightBase ^ setting' );
SELECT sys.uoc_constant( 'game.resources.weightBase' , '(test)' , 'Resources' , 10.0 );
SELECT is_empty( $$
SELECT * FROM emp.scaled_mining_weights_view
WHERE pmc_weight IS NULL
OR pmc_weight <> POW( 10 , resource_name_id )
$$ );
SELECT * FROM finish( );
ROLLBACK;