/*
* 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;
* Function that returns a string's identifier
CREATE FUNCTION _get_string( TEXT ) RETURNS INT AS $$
SELECT id FROM defs.strings WHERE name = $1;
* 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;
CREATE FUNCTION _create_test_strings( _quantity INT , _prefix TEXT )
SELECT _create_test_strings( $1 , $2 , 'Test string #' );
* Function that creates some quantity of test strings
CREATE FUNCTION _create_test_strings( _quantity INT )
SELECT _create_test_strings( $1 , 'test' );