diff options
author | dakkar <dakkar@thenautilus.net> | 2016-10-21 18:17:29 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2016-10-21 18:25:44 +0100 |
commit | e688b27ef71b0b86953755d54f30bdd0edbf2c32 (patch) | |
tree | 4e4b834eefd1bdef40f9d249effe1c0494e13fb8 /t/lib/Test | |
parent | fix test library for newer Test2::Compare (diff) | |
download | Sietima-e688b27ef71b0b86953755d54f30bdd0edbf2c32.tar.gz Sietima-e688b27ef71b0b86953755d54f30bdd0edbf2c32.tar.bz2 Sietima-e688b27ef71b0b86953755d54f30bdd0edbf2c32.zip |
FS mailstore & tests
the store has also gained a ->remove method
Diffstat (limited to 't/lib/Test')
-rw-r--r-- | t/lib/Test/Sietima/MailStore.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/t/lib/Test/Sietima/MailStore.pm b/t/lib/Test/Sietima/MailStore.pm index 60054c3..2925fd3 100644 --- a/t/lib/Test/Sietima/MailStore.pm +++ b/t/lib/Test/Sietima/MailStore.pm @@ -1,7 +1,8 @@ package Test::Sietima::MailStore; use Moo; use Sietima::Policy; -use List::AllUtils qw(all); +use List::AllUtils qw(all first_index); +use Digest::SHA1 qw(sha1_hex); use namespace::clean; with 'Sietima::MailStore'; @@ -14,10 +15,11 @@ has _mails => ( sub clear { shift->_mails([]) } sub store ($self,$mail,@tags) { - my $id = time(); + my $str = $mail->as_string; + my $id = sha1_hex($str); push $self->_mails->@*, { id => $id, - mail => $mail->as_string, + mail => $str, tags => { map {$_ => 1;} @tags, }, }; return $id; @@ -45,4 +47,11 @@ sub retrieve_by_id ($self,$id) { return; } +sub remove($self,$id) { + my $idx = first_index { $_->{id} eq $id } $self->_mails->@*; + return unless defined $idx; + splice $self->_mails->@*,$idx,1; + return; +} + 1; |