diff options
Diffstat (limited to 't')
-rw-r--r-- | t/lib/TestIndex.rakumod | 4 | ||||
-rw-r--r-- | t/store.t | 24 |
2 files changed, 22 insertions, 6 deletions
diff --git a/t/lib/TestIndex.rakumod b/t/lib/TestIndex.rakumod index c0b0b03..13043ac 100644 --- a/t/lib/TestIndex.rakumod +++ b/t/lib/TestIndex.rakumod @@ -5,7 +5,7 @@ unit class TestIndex does MaildirIndexer::Index; has %.mails; has $.name = 'test index'; -has @.responses = ( 'foo' xx 10 ); +has @.responses = ( Mailbox.new(:name('foo'),:1confidence) xx 10 ); has atomicint $!seen = 0; has Int $.expect; @@ -30,6 +30,6 @@ method del-path(IO:D $path, Str:D $mailbox --> Nil) { %.mails{$mailbox}{$path}:delete; } -method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) { +method mailbox-for-email(MaildirIndexer::Email:D $email --> Mailbox) { return @!responses.shift; } @@ -29,8 +29,24 @@ subtest 'indexing' => { subtest 'finding' => { my Channel $file-channel .= new; - my TestIndex $index1 .= new(:responses('1',Str,'1',Str),:name('index1')); - my TestIndex $index2 .= new(:responses('2',Str,Str,Str),:name('index2')); + my TestIndex $index1 .= new( + :responses( + Mailbox.new(:name('1'),:1confidence), + Mailbox, + Mailbox.new(:name('1'),:confidence(0.5)), + Mailbox + ), + :name('index1') + ); + my TestIndex $index2 .= new( + :responses( + Mailbox.new(:name('2'),:confidence(0.5)), + Mailbox, + Mailbox.new(:name('2'),:1confidence), + Mailbox + ), + :name('index2') + ); my MaildirIndexer::Store $store .= new( :$file-channel, @@ -43,8 +59,8 @@ subtest 'finding' => { is-deeply( @responses, - $['1','2','1',Str], - 'indexes are consulted until a defined value', + $['1',Str,'2',Str], + 'indexes are consulted, undefs ignored, highest confidence wins', ); } |