Server/Command/Delete.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 7 SCAR 35.9
CC
7
Cov
0%
validate
56.0
run
2.0
BEGIN
2.0
CRAP 36.4
1 package Net::IMAP::Server::Command::Delete;
2  
3 use warnings;
4 use strict;
5  
6 use base qw/Net::IMAP::Server::Command/;
7  
8 sub validate {
9 my $self = shift;
10  
11 return $self->bad_command("Log in first") if $self->connection->is_unauth;
12  
13 my @options = $self->parsed_options;
14 return $self->bad_command("Not enough options") if @options < 1;
15 return $self->bad_command("Too many options") if @options > 1;
16  
17 my $mailbox = $self->connection->model->lookup( @options );
18 return $self->no_command("Mailbox doesn't exist") unless $mailbox;
19 return $self->no_command("INBOX cannot be deleted") if $mailbox->is_inbox;
20 return $self->no_command("Mailbox has children") if @{$mailbox->children};
21  
22 return 1;
23 }
24  
25 sub run {
26 my $self = shift;
27  
28 my $mailbox = $self->connection->model->lookup($self->parsed_options);
29  
30 $mailbox->delete or return $self->no_command("Permission denied");
31  
32 $self->ok_completed();
33 }
34  
35 1;