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/utils/strings.sql
Emmanuel BENOîT 597429fadf In-game resources views
* Added session records to carry resource information over to the
clients

* Added SQL support code for the various views

* Added interface and implementation of the resource information access
component

* Hooked resources information queries into both the empire and planet
management component

* Added resources display to planet and overview pages
2012-02-04 10:43:12 +01:00

72 lines
1.5 KiB
PL/PgSQL

/*
* Utility functions used by unit tests
*
* I18N string creation and access
*/
/*
* Function that returns an invalid string identifier.
*/
CREATE FUNCTION _get_bad_string( ) RETURNS INT AS $$
SELECT MAX( id ) + 1 FROM defs.strings;
$$ LANGUAGE SQL;
/*
* Function that returns a language's identifier
*/
CREATE FUNCTION _get_language( TEXT ) RETURNS INT AS $$
SELECT id FROM defs.languages WHERE language = $1;
$$ LANGUAGE SQL;
/*
* Function that returns a string's identifier
*/
CREATE FUNCTION _get_string( TEXT ) RETURNS INT AS $$
SELECT id FROM defs.strings WHERE name = $1;
$$ LANGUAGE SQL;
/*
* Function that creates some quantity of test strings using a specific prefix
* and translation prefix.
*/
CREATE FUNCTION _create_test_strings( _quantity INT , _prefix TEXT , _trans TEXT )
RETURNS VOID
AS $$
DECLARE
i INT;
BEGIN
PERFORM defs.uoc_language( 't' , 'Test' );
i := 0;
WHILE i < _quantity
LOOP
i := i + 1;
PERFORM defs.uoc_translation( 't' , _prefix || i::TEXT ,
_trans || i::TEXT );
END LOOP;
END;
$$ LANGUAGE PLPGSQL;
/*
* Function that creates some quantity of test strings using a specific prefix
*/
CREATE FUNCTION _create_test_strings( _quantity INT , _prefix TEXT )
RETURNS VOID
AS $$
SELECT _create_test_strings( $1 , $2 , 'Test string #' );
$$ LANGUAGE SQL;
/*
* Function that creates some quantity of test strings
*/
CREATE FUNCTION _create_test_strings( _quantity INT )
RETURNS VOID
AS $$
SELECT _create_test_strings( $1 , 'test' );
$$ LANGUAGE SQL;