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/045-empire-mining/020-mset-update-set.sql

37 lines
1.5 KiB
MySQL
Raw Normal View History

/*
* Test the emp.mset_update_set() function
*/
BEGIN;
CREATE TEMPORARY TABLE mset_update(
empire_id INT ,
resource_name_id INT ,
empmset_weight INT
) ON COMMIT DROP;
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
/***** TESTS BEGIN HERE *****/
SELECT plan( 7 );
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update' );
SELECT ok( emp.mset_update_set( 1 , 1 ) );
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update results (1/2)' );
SELECT is( empmset_weight , 1 ) FROM mset_update WHERE resource_name_id = 1;
SELECT diag_test_name( 'emp.mset_update_set( ) - Valid update results (2/2)' );
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 2;
DELETE FROM mset_update;
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
SELECT diag_test_name( 'emp.mset_update_set( ) - Update on unknown resource' );
SELECT ok( NOT emp.mset_update_set( 12 , 1 ) );
SELECT diag_test_name( 'emp.mset_update_set( ) - Unknown resource update results (1/2)' );
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 1;
SELECT diag_test_name( 'emp.mset_update_set( ) - Unknown resource update results (2/2)' );
SELECT is( empmset_weight , 0 ) FROM mset_update WHERE resource_name_id = 2;
DELETE FROM mset_update;
INSERT INTO mset_update VALUES ( 1 , 1 , 0 ) , ( 1 , 2 , 0 );
SELECT diag_test_name( 'emp.mset_update_set( ) - Update with invalid weight' );
SELECT ok( emp.mset_update_set( 1 , -1 ) );
SELECT * FROM finish( );
ROLLBACK;