Server/Command/Fetch.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 51 CC 6 SCAR 30.9
CC
6
Cov
0%
validate
42.0
run
2.0
send_untagged
2.0
CRAP 22.0
1 package Net::IMAP::Server::Command::Fetch;
2  
3 use warnings;
4 use strict;
5  
6 use base qw/Net::IMAP::Server::Command/;
7  
8 use Coro;
9  
10 sub validate {
11 my $self = shift;
12  
13 return $self->bad_command("Login first") if $self->connection->is_unauth;
14 return $self->bad_command("Select a mailbox first")
15 unless $self->connection->is_selected;
16  
17 my @options = $self->parsed_options;
18 return $self->bad_command("Not enough options") if @options < 2;
19 return $self->bad_command("Too many options") if @options > 2;
20  
21 return $self->bad_command("Invalid message set")
22 unless $options[0] =~ $self->connection->SEQUENCE_STRING;
23  
24 return 1;
25 }
26  
27 sub run {
28 my $self = shift;
29  
30 my ( $messages, $spec ) = $self->parsed_options;
31 my @messages = $self->connection->get_messages($messages);
32 for my $m (@messages) {
33 $self->untagged_response( $self->connection->sequence($m)
34 . " FETCH "
35 . $self->data_out( [ $m->fetch($spec) ] ) );
36 cede;
37 }
38  
39 $self->ok_completed();
40 }
41  
42 sub send_untagged {
43 my $self = shift;
44  
45 $self->SUPER::send_untagged( expunged => 0 );
46 }
47  
48 1;