|
Lines 18-24
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::NoWarnings; |
20 |
use Test::NoWarnings; |
| 21 |
use Test::More tests => 9; |
21 |
use Test::More tests => 10; |
| 22 |
|
22 |
|
| 23 |
use Koha::Report; |
23 |
use Koha::Report; |
| 24 |
use Koha::Reports; |
24 |
use Koha::Reports; |
|
Lines 185-188
subtest '_might_add_limit' => sub {
Link Here
|
| 185 |
); |
185 |
); |
| 186 |
}; |
186 |
}; |
| 187 |
|
187 |
|
|
|
188 |
subtest 'apply_execution_time_limit' => sub { |
| 189 |
plan tests => 3; |
| 190 |
|
| 191 |
my $sql = "SELECT * FROM biblio"; |
| 192 |
|
| 193 |
t::lib::Mocks::mock_config( 'report_sql_max_statement_time_seconds', 0 ); |
| 194 |
is( Koha::Report->apply_execution_time_limit($sql), $sql, 'No execution time limit configured' ); |
| 195 |
|
| 196 |
t::lib::Mocks::mock_config( 'report_sql_max_statement_time_seconds', 1.5 ); |
| 197 |
my $context = Test::MockModule->new('C4::Context'); |
| 198 |
$context->mock( 'get_versions', sub { return ( mysqlVersion => '10.6.0-MariaDB' ); } ); |
| 199 |
is( |
| 200 |
Koha::Report->apply_execution_time_limit($sql), |
| 201 |
'SET STATEMENT max_statement_time=1.500000 FOR SELECT * FROM biblio', |
| 202 |
'MariaDB max statement time applied' |
| 203 |
); |
| 204 |
|
| 205 |
$context->mock( 'get_versions', sub { return ( mysqlVersion => '8.0.36' ); } ); |
| 206 |
like( |
| 207 |
Koha::Report->apply_execution_time_limit($sql), |
| 208 |
qr!^(?i:select) /\*\+ MAX_EXECUTION_TIME\(1500\) \*/ \* FROM biblio$!, |
| 209 |
'MySQL max execution time hint applied' |
| 210 |
); |
| 211 |
}; |
| 212 |
|
| 188 |
$schema->storage->txn_rollback; |
213 |
$schema->storage->txn_rollback; |
| 189 |
- |
|
|