86 lines
2.8 KiB
MySQL
86 lines
2.8 KiB
MySQL
|
/*
|
||
|
* Test the defs.uoc_technology() function for new technologies
|
||
|
*/
|
||
|
BEGIN;
|
||
|
\i utils/strings.sql
|
||
|
|
||
|
/*
|
||
|
* We need a few test strings to play with. Each technology definition
|
||
|
* uses four strings (name, category, discovery and description) so we'll
|
||
|
* create 8.
|
||
|
*/
|
||
|
SELECT _create_test_strings( 8 , 's' );
|
||
|
|
||
|
/*
|
||
|
* Manually insert an entry into the technologies table, using strings
|
||
|
* 5-8 for the various fields.
|
||
|
*/
|
||
|
INSERT INTO defs.technologies (
|
||
|
technology_name_id , technology_category_id ,
|
||
|
technology_discovery_id , technology_description_id ,
|
||
|
technology_price , technology_points
|
||
|
) VALUES (
|
||
|
_get_string( 's5' ) , _get_string( 's6' ) ,
|
||
|
_get_string( 's7' ) , _get_string( 's8' ) ,
|
||
|
1 , 1
|
||
|
);
|
||
|
|
||
|
-- ***** TESTS BEGIN HERE *****
|
||
|
SELECT plan( 10 );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid name string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
'does not exist' , 's2' , 's3' , 's4' , 1 , 1
|
||
|
)::TEXT , 'BAD_STRINGS' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid category string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 'does not exist' , 's3' , 's4' , 1 , 1
|
||
|
)::TEXT , 'BAD_STRINGS' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid discovery string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 'does not exist' , 's4' , 1 , 1
|
||
|
)::TEXT , 'BAD_STRINGS' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid description string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's3' , 'does not exist' , 1 , 1
|
||
|
)::TEXT , 'BAD_STRINGS' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid price' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's3' , 's4' , 0 , 1
|
||
|
)::TEXT , 'BAD_VALUE' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Invalid research points' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's3' , 's4' , 1 , 0
|
||
|
)::TEXT , 'BAD_VALUE' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Duplicate description string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's7' , 's4' , 1 , 1
|
||
|
)::TEXT , 'DUP_STRING' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Duplicate discovery string' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's3' , 's8' , 1 , 1
|
||
|
)::TEXT , 'DUP_STRING' );
|
||
|
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Success' );
|
||
|
SELECT is( defs.uoc_technology(
|
||
|
's1' , 's2' , 's3' , 's4' , 2 , 3
|
||
|
)::TEXT , 'CREATED' );
|
||
|
SELECT diag_test_name( 'defs.uoc_technology() - Creation - Row exists after success' );
|
||
|
SELECT set_eq( $$
|
||
|
SELECT * FROM defs.technologies
|
||
|
WHERE technology_name_id = _get_string( 's1' )
|
||
|
$$ , $$ VALUES(
|
||
|
_get_string( 's1' ) , _get_string( 's2' ) ,
|
||
|
_get_string( 's3' ) , _get_string( 's4' ) ,
|
||
|
2 , 3
|
||
|
) $$ );
|
||
|
|
||
|
SELECT * FROM finish( );
|
||
|
ROLLBACK;
|