57 lines
1.5 KiB
MySQL
57 lines
1.5 KiB
MySQL
|
/*
|
||
|
* Tests for defs.ordered_resources_view
|
||
|
*/
|
||
|
BEGIN;
|
||
|
|
||
|
/*
|
||
|
* We need:
|
||
|
* - one resource without category with weight 1,
|
||
|
* - one resource with category 1 and weight 2,
|
||
|
* - one resource with weight 4 and no category,
|
||
|
* - two resourcew with weights 3 and 7 and category 2.
|
||
|
*/
|
||
|
\i utils/strings.sql
|
||
|
SELECT _create_test_strings( 5 , 'resource' );
|
||
|
SELECT _create_test_strings( 5 , 'resDesc' );
|
||
|
SELECT _create_test_strings( 2 , 'resCat' );
|
||
|
|
||
|
INSERT INTO defs.resources(
|
||
|
resource_name_id , resource_description_id ,
|
||
|
resource_category_id , resource_weight
|
||
|
) VALUES (
|
||
|
_get_string( 'resource1' ) , _get_string( 'resDesc1' ) ,
|
||
|
NULL , 1
|
||
|
) , (
|
||
|
_get_string( 'resource2' ) , _get_string( 'resDesc2' ) ,
|
||
|
_get_string( 'resCat1' ) , 2
|
||
|
) , (
|
||
|
_get_string( 'resource3' ) , _get_string( 'resDesc3' ) ,
|
||
|
NULL , 4
|
||
|
) , (
|
||
|
_get_string( 'resource4' ) , _get_string( 'resDesc4' ) ,
|
||
|
_get_string( 'resCat2' ) , 3
|
||
|
) , (
|
||
|
_get_string( 'resource5' ) , _get_string( 'resDesc5' ) ,
|
||
|
_get_string( 'resCat2' ) , 7
|
||
|
);
|
||
|
|
||
|
SELECT plan( 1 );
|
||
|
SELECT diag_test_name( 'defs.ordered_resources_view - Resources are in the correct order' );
|
||
|
SELECT set_eq(
|
||
|
$$ SELECT resource_name_id , resource_ordering
|
||
|
FROM defs.ordered_resources_view $$ ,
|
||
|
$$ VALUES (
|
||
|
_get_string( 'resource1' ) , 1
|
||
|
) , (
|
||
|
_get_string( 'resource2' ) , 2
|
||
|
) , (
|
||
|
_get_string( 'resource3' ) , 3
|
||
|
) , (
|
||
|
_get_string( 'resource4' ) , 4
|
||
|
) , (
|
||
|
_get_string( 'resource5' ) , 5
|
||
|
) $$
|
||
|
);
|
||
|
|
||
|
SELECT * FROM finish( );
|
||
|
ROLLBACK;
|