#!perl
my
$source
= Pinto::Tester->new;
$source
->populate(
'AUTHOR/DistA-1 = PkgA~1'
);
$source
->populate(
'AUTHOR/DistB-1 = PkgB~1 & PkgD~1; PkgE~1'
);
$source
->populate(
'AUTHOR/DistC-1 = PkgC~1'
);
$source
->populate(
'AUTHOR/DistD-1 = PkgD~1'
);
subtest
'error causes rollback of all changes'
=>
sub
{
my
$local
= Pinto::Tester->new(
init_args
=> {
sources
=>
$source
->stack_url } );
$local
->run_throws_ok(
Pull
=> {
targets
=> [
qw(PkgA PkgB PkgC)
] },
qr/Cannot find PkgE~1 anywhere/
);
$local
->registration_not_ok(
'AUTHOR/DistA-1/PkgA~1/master'
);
$local
->registration_not_ok(
'AUTHOR/DistB-1/PkgB~1/master'
);
$local
->registration_not_ok(
'AUTHOR/DistC-1/PkgC~1/master'
);
$local
->registration_not_ok(
'AUTHOR/DistD-1/PkgD~1/master'
);
$local
->path_not_exists_ok( [
qw(stacks master authors id A AU AUTHOR DistA-1.tar.gz)
] );
$local
->path_not_exists_ok( [
qw(stacks master authors id A AU AUTHOR DistB-1.tar.gz)
] );
$local
->path_not_exists_ok( [
qw(stacks master authors id A AU AUTHOR DistD-1.tar.gz)
] );
$local
->path_not_exists_ok( [
qw(stacks master authors id A AU AUTHOR DistC-1.tar.gz)
] );
};
subtest
'error with no_fail flag only rolls back failed changes'
=>
sub
{
my
$local
= Pinto::Tester->new(
init_args
=> {
sources
=>
$source
->stack_url } );
$local
->run_throws_ok(
Pull
=> {
targets
=> [
qw(PkgA PkgB PkgC)
],
no_fail
=> 1 },
qr/Cannot find PkgE~1 anywhere/
,
'Result still a failure, even with no_fail'
);
$local
->stderr_like(
qr/Cannot find PkgE~1 anywhere/
);
$local
->stderr_like(
qr/PkgB~0 failed...continuing/
);
$local
->registration_ok(
'AUTHOR/DistA-1/PkgA~1/master'
,
'Target before failure ok'
);
$local
->registration_ok(
'AUTHOR/DistC-1/PkgC~1/master'
,
'Target after failure ok'
);
$local
->registration_not_ok(
'AUTHOR/DistB-1/PkgB~1/master'
,
'But failed target should not be there'
);
$local
->registration_not_ok(
'AUTHOR/DistD-1/PkgD~1/master'
,
'Dependency of failed target was unregisted'
);
my
$DistD
=
$local
->pinto->repo->get_distribution(
author
=>
'AUTHOR'
,
archive
=>
'DistD-1.tar.gz'
);
is
$DistD
,
undef
,
'Depedency of failed target is gone completely'
;
my
@dist_B
=
qw(stacks master authors id A AU AUTHOR DistB-1.tar.gz)
;
my
@dist_D
=
qw(stacks master authors id A AU AUTHOR DistD-1.tar.gz)
;
$local
->path_exists_ok( \
@dist_B
);
$local
->path_exists_ok( \
@dist_D
);
$local
->pinto->repo->clean_files;
$local
->path_not_exists_ok( \
@dist_B
);
$local
->path_not_exists_ok( \
@dist_D
);
};
done_testing;