Server/Command/Store.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 68 CC 11 SCAR 36.7
CC
11
Cov
0%
validate
72.0
run
20.0
send_untagged
2.0
CRAP 39.2
1 package Net::IMAP::Server::Command::Store;
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 return $self->bad_command("Mailbox is read-only") if $self->connection->selected->read_only;
18  
19 my @options = $self->parsed_options;
20 return $self->bad_command("Not enough options") if @options < 3;
21 return $self->bad_command("Too many options") if @options > 3;
22  
23 return $self->bad_command("Invalid message set")
24 unless $options[0] =~ $self->connection->SEQUENCE_STRING;
25  
26 return $self->bad_command("Invalid FLAGS option")
27 unless $options[1] =~ /^[+-]?FLAGS(\.SILENT)?$/;
28  
29 return 1;
30 }
31  
32 sub run {
33 my $self = shift;
34  
35 my ( $messages, $what, $flags ) = $self->parsed_options;
36 $flags = ref $flags ? $flags : [$flags];
37  
38 return $self->bad_command("Invalid flag $_") for grep {not $self->connection->selected->can_set_flag($_)} @{$flags};
39  
40 my @messages = $self->connection->get_messages($messages);
41 $self->connection->ignore_flags(1) if $what =~ /\.SILENT$/i;
42 for my $m (@messages) {
43 $m->store( $what => $flags );
44 cede;
45 }
46 $self->connection->ignore_flags(0) if $what =~ /\.SILENT$/i;
47  
48 $self->ok_completed();
49 }
50  
51 sub send_untagged {
52 my $self = shift;
53  
54 $self->SUPER::send_untagged( expunged => 0 );
55 }
56  
57 1;