This repository has been archived on 2025-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server-data/db-structure/tests/admin/040-functions/030-tech/060-techdep-clear.sql
Emmanuel BENOîT 1f3c7a9202 Technology definitions loader
* Added "dummy" data file for technologies (for now it simply copies the
old, line-based technologies) and corresponding XML schema

* Added missing SQL stored procedure to clear all dependencies and
reverse dependencies from a technology

* Added import classes, loader and import tool for the technology graph

* Added tech graph import tool to post-build tests
2012-02-27 20:04:02 +01:00

58 lines
No EOL
1.8 KiB
PL/PgSQL

/*
* Test the defs.techdep_clear() 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( 4 , 'tech' );
-- Insert the technologies
INSERT INTO defs.technologies ( technology_name_id )
VALUES ( _get_string( 'tech1' ) ) ,
( _get_string( 'tech2' ) ) ,
( _get_string( 'tech3' ) ) ,
( _get_string( 'tech4' ) );
-- Add a chain of dependencies
INSERT INTO defs.technology_dependencies(
technology_name_id , technology_name_id_depends
) VALUES ( _get_string( 'tech2' ) , _get_string( 'tech1' ) ) ,
( _get_string( 'tech3' ) , _get_string( 'tech2' ) ) ,
( _get_string( 'tech4' ) , _get_string( 'tech3' ) );
-- ***** TESTS BEGIN HERE *****
SELECT plan( 4 );
SELECT diag_test_name( 'defs.techdep_clear() - No failure on invalid technology name' );
SELECT lives_ok( $$
SELECT defs.techdep_clear( 'does not exist' )
$$ );
SELECT diag_test_name( 'defs.techdep_clear() - Successful call' );
SELECT lives_ok( $$
SELECT defs.techdep_clear( 'tech2' )
$$ );
SELECT diag_test_name( 'defs.techdep_clear() - Cleared technology has no dependencies' );
SELECT is_empty( $$
SELECT * FROM defs.technology_dependencies
WHERE technology_name_id = _get_string( 'tech2' );
$$ );
SELECT diag_test_name( 'defs.techdep_clear() - Cleared technology has no reverse dependencies' );
SELECT is_empty( $$
SELECT * FROM defs.technology_dependencies
WHERE technology_name_id_depends = _get_string( 'tech2' );
$$ );
SELECT * FROM finish( );
ROLLBACK;