App-Sqitch
view release on metacpan or search on metacpan
t/lib/DBIEngineTest.pm view on Meta::CPAN
throws_ok { $engine->log_deploy_change($rev_change) } 'App::Sqitch::X',
'Should re-throw if not a unique erorr';
is $@->ident, $DBI::state, 'Mode should be the error state';
is $@->message, $DBI::errstr, 'Should not have the underlying DB error';
}
}
# Make a temporary copy of the deploy file so we can restore it later.
my $deploy_file = $rev_change->deploy_file;
my $tmp_dir = dir( tempdir CLEANUP => 1 );
my $backup = $tmp_dir->file($deploy_file->basename);
ok $deploy_file->copy_to($backup), 'Back up deploy file';
# Modify the file so that its hash digest will vary.
delete $rev_change->{script_hash};
my $fh = $deploy_file->opena or die "Cannot open $deploy_file: $!\n";
try {
say $fh '-- Append line to reworked script so it gets a new SHA-1 hash';
close $fh;
isnt $rev_change->script_hash, $change2->script_hash,
'It should no longer have the same script hash';
lives_ok {
ok $engine->log_deploy_change($rev_change), 'Deploy the reworked change';
} 'The deploy should not fail';
} finally {
# Restore the reworked script.
$backup->copy_to($deploy_file);
};
# Make sure that change_id_for() chokes on the dupe.
MOCKVENT: {
my $sqitch_mocker = Test::MockModule->new(ref $sqitch);
my @args;
$sqitch_mocker->mock(vent => sub { shift; push @args => \@_ });
throws_ok { $engine->change_id_for( change => $name) } 'App::Sqitch::X',
'Should die on ambiguous change spec';
is $@->ident, 'engine', 'Mode should be "engine"';
( run in 0.587 second using v1.01-cache-2.11-cpan-49f99fa48dc )