Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add rename bag support

  • Loading branch information...
commit 1a493e5b6eb3ae577ea11322b6112e47b536cbeb 1 parent 55413c4
@dagolden authored
Showing with 16 additions and 8 deletions.
  1. +1 −1  lib/Pantry/App/Command/rename.pm
  2. +15 −7 t/app/rename.t
View
2  lib/Pantry/App/Command/rename.pm
@@ -18,7 +18,7 @@ sub command_type {
return 'DUAL_TARGET';
}
-my @types = qw/node role environment/;
+my @types = qw/node role environment bag/;
sub valid_types {
return @types;
View
22 t/app/rename.t
@@ -33,17 +33,25 @@ my @cases = (
name => 'test',
new => sub { my ($p,$n) = @_; $p->environment($n) },
},
+ {
+ label => "bag",
+ type => "bag",
+ name => 'user/xdg',
+ new_name => 'oldusers/xdg',
+ new => sub { my ($p,$n) = @_; $p->bag($n) },
+ },
);
local $ENV{PERL_MM_USE_DEFAULT} = 1;
for my $c ( @cases ) {
+ my $new_name = $c->{new_name} // 'renamed';
subtest "$c->{label}: rename" => sub {
my ($wd, $pantry) = _create_pantry();
my $obj = $c->{new}->($pantry, $c->{name});
- my $new = $c->{new}->($pantry, "renamed");
+ my $new = $c->{new}->($pantry, $new_name);
_try_command('create', $c->{type}, $c->{name}, @{$c->{args}||[]});
- _try_command('rename', $c->{type}, $c->{name}, "renamed", @{$c->{args}||[]});
+ _try_command('rename', $c->{type}, $c->{name}, $new_name, @{$c->{args}||[]});
ok( ! -e $obj->path, "original object is gone" );
ok( -e $new->path, "renamed object exists" );
};
@@ -51,8 +59,8 @@ for my $c ( @cases ) {
subtest "$c->{label}: rename missing" => sub {
my ($wd, $pantry) = _create_pantry();
my $obj = $c->{new}->($pantry, $c->{name});
- my $new = $c->{new}->($pantry, "renamed");
- my $result = _try_command('rename', $c->{type}, $c->{name}, "renamed", @{$c->{args}||[]}, { exit_code => -1});
+ my $new = $c->{new}->($pantry, $new_name);
+ my $result = _try_command('rename', $c->{type}, $c->{name}, $new_name, @{$c->{args}||[]}, { exit_code => -1});
like( $result->error, qr/does not exist/, "error message" );
ok( ! -e $obj->path, "original object not there" );
ok( ! -e $new->path, "renamed object not there" );
@@ -61,10 +69,10 @@ for my $c ( @cases ) {
subtest "$c->{label}: rename won't clobber" => sub {
my ($wd, $pantry) = _create_pantry();
my $obj = $c->{new}->($pantry, $c->{name});
- my $new = $c->{new}->($pantry, "renamed");
+ my $new = $c->{new}->($pantry, $new_name);
_try_command('create', $c->{type}, $c->{name}, @{$c->{args}||[]});
- _try_command('create', $c->{type}, "renamed", @{$c->{args}||[]});
- my $result = _try_command('rename', $c->{type}, $c->{name}, "renamed", @{$c->{args}||[]}, { exit_code => -1});
+ _try_command('create', $c->{type}, $new_name, @{$c->{args}||[]});
+ my $result = _try_command('rename', $c->{type}, $c->{name}, $new_name, @{$c->{args}||[]}, { exit_code => -1});
like( $result->error, qr/already exists/, "error message" );
ok( -e $obj->path, "original object is there" );
ok( -e $new->path, "existing object is there" );
Please sign in to comment.
Something went wrong with that request. Please try again.