diff options
Diffstat (limited to 't/store.t')
-rw-r--r-- | t/store.t | 63 |
1 files changed, 40 insertions, 23 deletions
@@ -6,28 +6,45 @@ use TestIndex; use MaildirIndexer::Store; use MaildirIndexer::Index; -my Channel $file-channel .= new; -my TestIndex $index .= new; -my MaildirIndexer::Store $store .= new: :$file-channel, :indices($index), :2workers; - -$store.start(); - -$index.set-expect(4); -$file-channel.send("t/fixtures/$_".IO) for qw[one/cur/1 one/cur/2 two/cur/1 two/cur/2]; -await $index.seen-all; - -is-deeply( - $index.mails, - %( - one => %( 't/fixtures/one/cur/1' => 1, 't/fixtures/one/cur/2' => 1 ), - two => %( 't/fixtures/two/cur/1' => 1, 't/fixtures/two/cur/2' => 1 ), - ), - 'mails should be indexed', -); - -is( - $store.mailbox-for-email(MaildirIndexer::Email.new),'foo', - 'index is consulted', -); +subtest 'indexing' => { + my Channel $file-channel .= new; + my TestIndex $index .= new; + my MaildirIndexer::Store $store .= new: :$file-channel, :indices($index), :2workers; + + $store.start(); + + $index.set-expect(4); + $file-channel.send("t/fixtures/$_".IO) for qw[one/cur/1 one/cur/2 two/cur/1 two/cur/2]; + await $index.seen-all; + + is-deeply( + $index.mails, + %( + one => %( 't/fixtures/one/cur/1' => 1, 't/fixtures/one/cur/2' => 1 ), + two => %( 't/fixtures/two/cur/1' => 1, 't/fixtures/two/cur/2' => 1 ), + ), + 'mails should be indexed', + ); +} + +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),:name('index2')); + + my MaildirIndexer::Store $store .= new( + :$file-channel, + :indices($index1,$index2), + :1workers, + ); + + my @responses = $store.mailbox-for-email(MaildirIndexer::Email.new) xx 4; + + is-deeply( + @responses, + $['1','2','1',Str], + 'indexes are consulted until a defined value', + ); +} done-testing; |