summaryrefslogtreecommitdiff
path: root/t/lib/TestIndex.rakumod
diff options
context:
space:
mode:
Diffstat (limited to 't/lib/TestIndex.rakumod')
-rw-r--r--t/lib/TestIndex.rakumod35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/lib/TestIndex.rakumod b/t/lib/TestIndex.rakumod
new file mode 100644
index 0000000..c0b0b03
--- /dev/null
+++ b/t/lib/TestIndex.rakumod
@@ -0,0 +1,35 @@
+use v6.d;
+use MaildirIndexer::Index;
+
+unit class TestIndex does MaildirIndexer::Index;
+
+has %.mails;
+has $.name = 'test index';
+has @.responses = ( 'foo' 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 $email, Str: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 --> Str) {
+ return @!responses.shift;
+}