|
Lines 30-36
use Koha::AtomicUpdater;
Link Here
|
| 30 |
|
30 |
|
| 31 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 32 |
|
32 |
|
| 33 |
plan tests => 9; |
33 |
plan tests => 10; |
| 34 |
|
34 |
|
| 35 |
my $schema = Koha::Database->new->schema; |
35 |
my $schema = Koha::Database->new->schema; |
| 36 |
$schema->storage->txn_begin; |
36 |
$schema->storage->txn_begin; |
|
Lines 304-312
subtest 'Mark all atomicupdates as installed (for fresh installs), but do not ex
Link Here
|
| 304 |
$test_file2->remove; |
304 |
$test_file2->remove; |
| 305 |
}; |
305 |
}; |
| 306 |
|
306 |
|
| 307 |
$test_file->remove; |
|
|
| 308 |
$schema->storage->txn_rollback; |
307 |
$schema->storage->txn_rollback; |
| 309 |
|
308 |
|
|
|
309 |
subtest 'Support community dev atomicupdates (.perl files, see skeleton.perl)' => sub { |
| 310 |
|
| 311 |
plan tests => 4; |
| 312 |
$schema->storage->txn_begin; |
| 313 |
|
| 314 |
my $dev_update = q{ |
| 315 |
$DBversion = 'XXX'; # will be replaced by the RM |
| 316 |
if( CheckVersion( $DBversion ) ) { |
| 317 |
$dbh->do( "SHOW TABLES" ); |
| 318 |
|
| 319 |
# Always end with this (adjust the bug info) |
| 320 |
SetVersion( $DBversion ); |
| 321 |
$ENV{ATOMICUPDATE_TESTS_VAL}++; |
| 322 |
print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; |
| 323 |
} |
| 324 |
}; |
| 325 |
|
| 326 |
my $dev_update_invalid = q{ |
| 327 |
$DBversion = '16.00.00'; # will be replaced by the RM |
| 328 |
if( CheckVersion( $DBversion ) ) { |
| 329 |
$dbh->do( "SHOW TABLES" ); |
| 330 |
|
| 331 |
# Always end with this (adjust the bug info) |
| 332 |
SetVersion( $DBversion ); |
| 333 |
$ENV{ATOMICUPDATE_TESTS_INV}++; |
| 334 |
print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; |
| 335 |
} |
| 336 |
}; |
| 337 |
|
| 338 |
my $test_file1 = create_file({ |
| 339 |
filepath => 'atomicupdate/', |
| 340 |
filename => 'Bug_00001-First-update.perl', |
| 341 |
content => $dev_update, |
| 342 |
}); |
| 343 |
|
| 344 |
my $test_file2 = create_file({ |
| 345 |
filepath => 'atomicupdate/', |
| 346 |
filename => 'Bug_00002-Invalid-update.perl', |
| 347 |
content => $dev_update_invalid, |
| 348 |
}); |
| 349 |
|
| 350 |
my $atomicUpdater = Koha::AtomicUpdater->new({ |
| 351 |
scriptDir => $test_file->dirname(), |
| 352 |
}); |
| 353 |
|
| 354 |
my $atomicUpdater_invalid = Koha::AtomicUpdater->new({ |
| 355 |
scriptDir => $test_file->dirname(), |
| 356 |
}); |
| 357 |
|
| 358 |
$atomicUpdater->applyAtomicUpdate( $test_file1->stringify ); |
| 359 |
|
| 360 |
$atomicUpdater_invalid->applyAtomicUpdate( $test_file2->stringify ); |
| 361 |
|
| 362 |
my $atomicUpdate = $atomicUpdater->find('Bug-00001'); |
| 363 |
my $atomicUpdate_invalid = $atomicUpdater->find('Bug-00002'); |
| 364 |
|
| 365 |
is($atomicUpdate->filename, "Bug_00001-First-update.perl", "Bug_00001-First-update.perl added to DB"); |
| 366 |
is($atomicUpdate_invalid->filename, "Bug_00002-Invalid-update.perl", "Bug_00002-Invalid-update.perl added to DB"); |
| 367 |
is($ENV{ATOMICUPDATE_TESTS_VAL}, 1, "First update execution success."); |
| 368 |
is($ENV{ATOMICUPDATE_TESTS_INV}, undef, "Invalid update execution failed."); |
| 369 |
|
| 370 |
$test_file1->remove; |
| 371 |
$test_file2->remove; |
| 372 |
$schema->storage->txn_rollback; |
| 373 |
}; |
| 374 |
|
| 375 |
$test_file->remove; |
| 376 |
|
| 310 |
sub create_file { |
377 |
sub create_file { |
| 311 |
my ($file) = @_; |
378 |
my ($file) = @_; |
| 312 |
my $tmpdir = File::Spec->tmpdir(); |
379 |
my $tmpdir = File::Spec->tmpdir(); |
| 313 |
- |
|
|