]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/lei.t
lei q: start wiring up saved search
[public-inbox.git] / t / lei.t
diff --git a/t/lei.t b/t/lei.t
index 2e0b8a1fe9173b28562c784408d54184a8a3d7ed..6ade2f180198dca246b9c34d7d8af06ce94b77dc 100644 (file)
--- a/t/lei.t
+++ b/t/lei.t
@@ -93,6 +93,15 @@ my $test_config = sub {
                        'config set var with -f fails');
        like($lei_err, qr/not supported/, 'not supported noted');
        ok(!-f "$home/config/f", 'no file created');
+
+       lei_ok(qw(-c imap.debug config --bool imap.debug));
+       is($lei_out, "true\n", "-c sets w/o value");
+       lei_ok(qw(-c imap.debug=1 config --bool imap.debug));
+       is($lei_out, "true\n", "-c coerces value");
+       lei_ok(qw(-c imap.debug=tr00 config imap.debug));
+       is($lei_out, "tr00\n", "-c string value passed as-is");
+       lei_ok(qw(-c imap.debug=a -c imap.debug=b config --get-all imap.debug));
+       is($lei_out, "a\nb\n", '-c and --get-all work together');
 };
 
 my $test_completion = sub {
@@ -105,7 +114,7 @@ my $test_completion = sub {
        %out = map { $_ => 1 } split(/\s+/s, $lei_out);
        for my $sw (qw(-f --format -o --output --mfolder --augment -a
                        --mua --no-local --local --verbose -v
-                       --save-as --no-remote --remote --torsocks
+                       --save --no-remote --remote --torsocks
                        --reverse -r )) {
                ok($out{$sw}, "$sw offered as `lei q' completion");
        }
@@ -129,12 +138,30 @@ my $test_completion = sub {
 };
 
 my $test_fail = sub {
+       lei('q', 'whatever', '-C', '/dev/null');
+       is($? >> 8, 1, 'chdir at end fails to /dev/null');
+       lei('-C', '/dev/null', 'q', 'whatever');
+       is($? >> 8, 1, 'chdir at beginning fails to /dev/null');
+
+       for my $lk (qw(ei inbox)) {
+               my $d = "$home/newline\n$lk";
+               mkdir $d;
+               open my $fh, '>', "$d/$lk.lock" or BAIL_OUT "open $d/$lk.lock";
+               for my $fl (qw(-I --only)) {
+                       ok(!lei('q', $fl, $d, 'whatever'),
+                               "newline $lk.lock fails with q $fl");
+                       like($lei_err, qr/`\\n' not allowed/,
+                               "error noted with q $fl");
+               }
+       }
+       lei_ok('sucks', \'yes, but hopefully less every day');
 SKIP: {
        skip 'no curl', 3 unless which('curl');
        lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m));
        is($? >> 8, 3, 'got curl exit for bogus URL');
        lei(qw(q --only http://127.0.0.1:99999/bogus/ t:m -o), "$home/junk");
-       is($? >> 8, 3, 'got curl exit for bogus URL with Maildir');
+       is($? >> 8, 3, 'got curl exit for bogus URL with Maildir') or
+               diag $lei_err;
        is($lei_out, '', 'no output');
 }; # /SKIP
 };