X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fwatch_maildir.t;h=a5fb52b2b083a1a94995b2849eaf8c699497b501;hb=7c5ac90b309bbe76468055e8a9289664ef2dfe37;hp=e12e0836b824d3f6b7141d31194f1dd48c9f8429;hpb=f9b70eb6ebbf96c2fe79ab2738ea4954c5a124f3;p=public-inbox.git
diff --git a/t/watch_maildir.t b/t/watch_maildir.t
index e12e0836..a5fb52b2 100644
--- a/t/watch_maildir.t
+++ b/t/watch_maildir.t
@@ -1,17 +1,13 @@
-# Copyright (C) 2016 all contributors
+# Copyright (C) 2016-2019 all contributors
# License: AGPL-3.0+
+use strict;
use Test::More;
-use File::Temp qw/tempdir/;
use Email::MIME;
use Cwd;
use PublicInbox::Config;
-my @mods = qw(Filesys::Notify::Simple);
-foreach my $mod (@mods) {
- eval "require $mod";
- plan skip_all => "$mod missing for watch_maildir.t" if $@;
-}
-
-my $tmpdir = tempdir('watch_maildir-XXXXXX', TMPDIR => 1, CLEANUP => 1);
+use PublicInbox::TestCommon;
+require_mods(qw(Filesys::Notify::Simple));
+my ($tmpdir, $for_destroy) = tmpdir();
my $git_dir = "$tmpdir/test.git";
my $maildir = "$tmpdir/md";
my $spamdir = "$tmpdir/spam";
@@ -31,16 +27,17 @@ Date: Sat, 18 Jun 2016 00:00:00 +0000
something
EOF
PublicInbox::Emergency->new($maildir)->prepare(\$msg);
-ok(POSIX::mkfifo("$maildir/cur/fifo", 0777));
+ok(POSIX::mkfifo("$maildir/cur/fifo", 0777),
+ 'create FIFO to ensure we do not get stuck on it :P');
my $sem = PublicInbox::Emergency->new($spamdir); # create dirs
-my $config = PublicInbox::Config->new({
- "$cfgpfx.address" => $addr,
- "$cfgpfx.mainrepo" => $git_dir,
- "$cfgpfx.watch" => "maildir:$maildir",
- "$cfgpfx.filter" => 'PublicInbox::Filter::Vger',
- "publicinboxlearn.watchspam" => "maildir:$spamdir",
-});
+my $config = PublicInbox::Config->new(\<new($config)->scan('full');
my $git = PublicInbox::Git->new($git_dir);
@@ -123,4 +120,13 @@ More majordomo info at http://vger.kernel.org/majordomo-info.html\n);
like($$mref, qr/something\n\z/s, 'message scrubbed on import');
}
+sub is_maildir {
+ my ($dir) = @_;
+ PublicInbox::WatchMaildir::is_maildir($dir);
+}
+
+is(is_maildir('maildir:/hello//world'), '/hello/world', 'extra slash gone');
+is(is_maildir('maildir:/hello/world/'), '/hello/world', 'trailing slash gone');
+is(is_maildir('faildir:/hello/world/'), undef, 'non-maildir rejected');
+
done_testing;