about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-27 10:03:41 +0000
committerEric Wong <e@yhbt.net>2020-06-28 22:27:18 +0000
commit67592c40510dae8604580cf4b2a0a0f665b84501 (patch)
tree426f2abd4af167df7b7f3e49d5ea95e7dfe8b773 /t
parentbbf4159b7694241d2139be641ced4c485303714a (diff)
downloadpublic-inbox-67592c40510dae8604580cf4b2a0a0f665b84501.tar.gz
config: support ->urlmatch method for -watch
Since we have IMAP client support in -watch; make sure per-URL
settings are familiar to git users by taking advantage of git's
URL matching abilities.

This requires git 1.8.5+, which most users ought to have
(though base CentOS 7 is on 1.8.3).
Diffstat (limited to 't')
-rw-r--r--t/config.t18
-rw-r--r--t/imapd.t2
2 files changed, 19 insertions, 1 deletions
diff --git a/t/config.t b/t/config.t
index 3f41c004..ad543ad3 100644
--- a/t/config.t
+++ b/t/config.t
@@ -225,4 +225,22 @@ EOF
                 'bogus is undef');
 }
 
+SKIP: {
+        require_git('1.8.5', 2) or
+                skip 'git 1.8.5+ required for --url-match', 2;
+        my $f = "$tmpdir/urlmatch";
+        open my $fh, '>', $f or BAIL_OUT $!;
+        print $fh <<EOF or BAIL_OUT $!;
+[imap "imap://*.example.com"]
+        pollInterval = 9
+EOF
+        close $fh or BAIL_OUT;
+        local $ENV{PI_CONFIG} = $f;
+        my $cfg = PublicInbox::Config->new;
+        my $url = 'imap://mail.example.com/INBOX';
+        is($cfg->urlmatch('imap.pollInterval', $url), 9, 'urlmatch hit');
+        is($cfg->urlmatch('imap.idleInterval', $url), undef, 'urlmatch miss');
+};
+
+
 done_testing();
diff --git a/t/imapd.t b/t/imapd.t
index ee3a3b26..5626d247 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -486,7 +486,7 @@ ok($mic->logout, 'logged out');
 
         # try again with polling
         xsys(qw(git config), "--file=$home/.public-inbox/config",
-                "imap.imap://$ihost:$iport.PollInterval", 0.11) == 0
+                'imap.PollInterval', 0.11) == 0
                 or BAIL_OUT "git config $?";
         $w->kill('HUP');
         diag 'waiting for -watch reload + initial fetch';