35 lines
845 B
MySQL
35 lines
845 B
MySQL
|
/*
|
||
|
* Test emp.total_mining_weights_view
|
||
|
*/
|
||
|
BEGIN;
|
||
|
/* Create a table which will server as an alternate source for
|
||
|
* emp.total_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_weights(
|
||
|
empire_id INT ,
|
||
|
technology_name_id INT ,
|
||
|
emptech_weight DOUBLE PRECISION
|
||
|
);
|
||
|
|
||
|
CREATE OR REPLACE VIEW emp.research_weights_view
|
||
|
AS SELECT * FROM fake_weights;
|
||
|
|
||
|
/* Insert fake records for two different empires */
|
||
|
INSERT INTO fake_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 emp.research_total_weights_view $$ ,
|
||
|
$$ VALUES ( 1 , 3.0 ) , ( 2 , 9.0 ) $$
|
||
|
);
|
||
|
|
||
|
SELECT * FROM finish( );
|
||
|
ROLLBACK;
|