summaryrefslogtreecommitdiff
path: root/t/lib/TestIndex.rakumod
blob: 13043ac2927ed1b32b7ee9dbdaebd9f667de4b6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use v6.d;
use MaildirIndexer::Index;
 
unit class TestIndex does MaildirIndexer::Index;
 
has %.mails;
has $.name = 'test index';
has @.responses = ( Mailbox.new(:name('foo'),:1confidence) xx 10 );
 
has atomicint $!seen = 0;
has Int $.expect;
has $.seen-all;
has $!seen-all-vow;
 
method set-expect(Int:D $!expect{
    $!seen ⚛= 0;
    $!seen-all = Promise.new;
    $!seen-all-vow = $!seen-all.vow;
}
    
method add-mail(MaildirIndexer::Email:D $emailStr:D $mailbox --> Nil{
    %.mails{$mailbox}{$email.path}=1;
    ++⚛$!seen;
    if ($!seen == $!expect{
        $!seen-all-vow.keep(True)
    }
}
 
method del-path(IO:D $path, Str:D $mailbox --> Nil{
    %.mails{$mailbox}{$path}:delete;
}
 
method mailbox-for-email(MaildirIndexer::Email:D $email --> Mailbox{
    return @!responses.shift;
}