AnyEvent-FTP
view release on metacpan or search on metacpan
t/anyevent_ftp_server_context_memory__rename.t view on Meta::CPAN
my $store = AnyEvent::FTP::Server::Context::Memory->store;
$store->{dir}->{"foo.txt"} = "hello there";
my $t = create_ftpserver_ok('Memory');
$t->command_ok(RNTO => "dir/bar.txt")
->code_is(503)
->message_is('Bad sequence of commands');
$t->command_ok(RNFR => "dir/bogus.txt")
->code_is(550)
->message_is('No such file or directory');
$t->command_ok(RNFR => "bogus/bogus.txt")
->code_is(550)
->message_is('No such file or directory');
$t->command_ok(RNFR => "dir/foo.txt")
->code_is(350)
->message_is('File or directory exists, ready for destination name');
$t->command_ok(RNTO => "dir/bar.txt")
->code_is(250)
->message_is('Rename successful');
ok !exists $store->{dir}->{"foo.txt"}, "file removed";
is $store->{dir}->{"bar.txt"}, "hello there", "file moved";
$store->{dir}->{"bar.txt"} = "hello there";
$store->{dir}->{"foo.txt"} = "hello there";
$t->command_ok(RNFR => "dir/foo.txt")
->code_is(350)
->message_is('File or directory exists, ready for destination name');
$t->command_ok(RNTO => "dir/bar.txt")
->code_is(550)
->message_is('File already exists');
$t->command_ok(RNFR => "dir/foo.txt")
->code_is(350)
->message_is('File or directory exists, ready for destination name');
$t->command_ok(RNTO => "bogus/bogus.txt")
->code_is(550)
->message_is('Rename failed');
$t->command_ok(RNFR => "/")
->code_is(550)
->message_is('No such file or directory');
$t->command_ok(RNFR => "../")
->code_is(550)
->message_is('No such file or directory');
$t->command_ok(RNFR => "dir/foo.txt")
->code_is(350)
->message_is('File or directory exists, ready for destination name');
todo "shouldn't be able to rename to root" => sub {
$t->command_ok(RNTO => "/")
->code_is(550);
};
done_testing;
( run in 2.433 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )