+ ok(!$lei->(qw(q --no-local s:see)), '--no-local');
+ is($? >> 8, 1, 'proper exit code');
+ like($err, qr/no local or remote.+? to search/, 'no inbox');
+ my %e = (
+ TEST_LEI_EXTERNAL_HTTPS => 'https://public-inbox.org/meta/',
+ TEST_LEI_EXTERNAL_ONION => $onions[int(rand(scalar(@onions)))],
+ );
+ for my $k (keys %e) {
+ my $url = $ENV{$k} // '';
+ $url = $e{$k} if $url eq '1';
+ $test_external_remote->($url, $k);
+ }
+};
+
+my $test_completion = sub {
+ ok($lei->(qw(_complete lei)), 'no errors on complete');
+ my %out = map { $_ => 1 } split(/\s+/s, $out);
+ ok($out{'q'}, "`lei q' offered as completion");
+ ok($out{'add-external'}, "`lei add-external' offered as completion");
+
+ ok($lei->(qw(_complete lei q)), 'complete q (no args)');
+ %out = map { $_ => 1 } split(/\s+/s, $out);
+ for my $sw (qw(-f --format -o --output --mfolder --augment -a
+ --mua --mua-cmd --no-local --local --verbose -v
+ --save-as --no-remote --remote --torsocks
+ --reverse -r )) {
+ ok($out{$sw}, "$sw offered as completion");
+ }
+
+ ok($lei->(qw(_complete lei q --form)), 'complete q --format');
+ is($out, "--format\n", 'complete lei q --format');
+ for my $sw (qw(-f --format)) {
+ ok($lei->(qw(_complete lei q), $sw), "complete q $sw ARG");
+ %out = map { $_ => 1 } split(/\s+/s, $out);
+ for my $f (qw(mboxrd mboxcl2 mboxcl mboxo json jsonl
+ concatjson maildir)) {
+ ok($out{$f}, "got $sw $f as output format");
+ }
+ }
+};
+
+my $test_fail = sub {
+ $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($out, '', 'no output');