Emmanuel BENOîT
af57e7d3b5
* Added stored procedures which manipulate technology definitions themselves (defs.uoc_technology) or their dependencies (defs.techdep_add and defs.techdep_remove)
51 lines
No EOL
1.8 KiB
PL/PgSQL
51 lines
No EOL
1.8 KiB
PL/PgSQL
/*
|
|
* Test the defs.techdep_remove() function
|
|
*/
|
|
BEGIN;
|
|
\i utils/strings.sql
|
|
-- Make the columns we don't use in the technology definition table NULL-able
|
|
ALTER TABLE defs.technologies
|
|
ALTER technology_category_id DROP NOT NULL ,
|
|
ALTER technology_discovery_id DROP NOT NULL ,
|
|
ALTER technology_description_id DROP NOT NULL ,
|
|
ALTER technology_price DROP NOT NULL ,
|
|
ALTER technology_points DROP NOT NULL;
|
|
|
|
-- Create strings to use as the technologies' names
|
|
SELECT _create_test_strings( 2 , 'tech' );
|
|
|
|
-- Insert the technologies
|
|
INSERT INTO defs.technologies ( technology_name_id )
|
|
VALUES ( _get_string( 'tech1' ) ) ,
|
|
( _get_string( 'tech2' ) );
|
|
|
|
-- Add a dependency from tech2 to tech1
|
|
INSERT INTO defs.technology_dependencies(
|
|
technology_name_id , technology_name_id_depends
|
|
) VALUES ( _get_string( 'tech2' ) , _get_string( 'tech1' ) );
|
|
|
|
|
|
-- ***** TESTS BEGIN HERE *****
|
|
SELECT plan( 5 );
|
|
|
|
SELECT diag_test_name( 'defs.techdep_remove() - Bad dependent technology name' );
|
|
SELECT is( defs.techdep_remove( 'does not exist' , 'tech1' )::TEXT , 'MISSING' );
|
|
|
|
SELECT diag_test_name( 'defs.techdep_remove() - Bad dependency name' );
|
|
SELECT is( defs.techdep_remove( 'tech2' , 'does not exist' )::TEXT , 'MISSING' );
|
|
|
|
SELECT diag_test_name( 'defs.techdep_remove() - Correct name but no dependency' );
|
|
SELECT is( defs.techdep_remove( 'tech1' , 'tech2' )::TEXT , 'MISSING' );
|
|
|
|
SELECT diag_test_name( 'defs.techdep_remove() - Success - Return value' );
|
|
SELECT is( defs.techdep_remove( 'tech2' , 'tech1' )::TEXT , 'DELETED' );
|
|
|
|
SELECT diag_test_name( 'defs.techdep_remove() - Success - Table contents' );
|
|
SELECT is_empty($$
|
|
SELECT * FROM defs.technology_dependencies
|
|
WHERE technology_name_id = _get_string( 'tech2' )
|
|
AND technology_name_id_depends = _get_string( 'tech1' );
|
|
$$);
|
|
|
|
SELECT * FROM finish( );
|
|
ROLLBACK; |