- ok(!$lei->('add-external', "$home/nonexistent"),
- "fails on non-existent dir");
- $lei->('ls-external');
- is($out.$err, '', 'ls-external still has no output');
- my $cfg = PublicInbox::Config->new;
- $cfg->each_inbox(sub {
- my ($ibx) = @_;
- ok($lei->(qw(add-external -q), $ibx->{inboxdir}),
- 'added external');
- is($out.$err, '', 'no output');
- });
- ok(-s $config_file && -e $store_dir,
- 'add-external created config + store');
- my $lcfg = PublicInbox::Config->new($config_file);
- $cfg->each_inbox(sub {
- my ($ibx) = @_;
- is($lcfg->{"external.$ibx->{inboxdir}.boost"}, 0,
- "configured boost on $ibx->{name}");
- });
- $lei->('ls-external');
- like($out, qr/boost=0\n/s, 'ls-external has output');
- ok($lei->(qw(add-external -q https://EXAMPLE.com/ibx)), 'add remote');
- is($err, '', 'no warnings after add-external');
- $lei->('ls-external');
- like($out, qr!https://example\.com/ibx/!s, 'added canonical URL');
- is($err, '', 'no warnings on ls-external');
- ok($lei->(qw(forget-external -q https://EXAMPLE.com/ibx)),
- 'forget');
- $lei->('ls-external');
- unlike($out, qr!https://example\.com/ibx/!s, 'removed canonical URL');
-
- ok(!$lei->(qw(q s:prefix -o /dev/null -f maildir)), 'bad maildir');
- like($err, qr!/dev/null exists and is not a directory!,
- 'error shown');
- is($? >> 8, 1, 'errored out with exit 1');
-
- ok(!$lei->(qw(q s:prefix -f mboxcl2 -o), $home), 'bad mbox');
- like($err, qr!\Q$home\E exists and is not a writable file!,
- 'error shown');
- is($? >> 8, 1, 'errored out with exit 1');
-
- ok(!$lei->(qw(q s:prefix -o /dev/stdout -f Mbox2)), 'bad format');
- like($err, qr/bad mbox --format=mbox2/, 'error shown');
- is($? >> 8, 1, 'errored out with exit 1');
-
- # note, on a Bourne shell users should be able to use either:
- # s:"use boolean prefix"
- # "s:use boolean prefix"
- # or use single quotes, it should not matter. Users only need
- # to know shell quoting rules, not Xapian quoting rules.
- # No double-quoting should be imposed on users on the CLI
- $lei->('q', 's:use boolean prefix');
- like($out, qr/search: use boolean prefix/, 'phrase search got result');
- my $res = $json->decode($out);
- is(scalar(@$res), 2, 'only 2 element array (1 result)');
- is($res->[1], undef, 'final element is undef'); # XXX should this be?
- is(ref($res->[0]), 'HASH', 'first element is hashref');
- $lei->('q', '--pretty', 's:use boolean prefix');
- my $pretty = $json->decode($out);
- is_deeply($res, $pretty, '--pretty is identical after decode');
-
- for my $fmt (qw(ldjson ndjson jsonl)) {
- $lei->('q', '-f', $fmt, 's:use boolean prefix');
- is($out, $json->encode($pretty->[0])."\n", "-f $fmt");