- my $res = cgi_run("/test/all.atom.xml");
- like($res->{body}, qr/<title>test for public-inbox/,
- "set title in XML feed");
- like($res->{body},
- qr!http://test\.example\.com/test/mid/blah%40example\.com!,
- "link id set");
- like($res->{body}, qr/what\?/, "reply included");
-
- $res = cgi_run("/test/index.atom.xml");
- unlike($res->{body}, qr/what\?/, "reply not included in index");
+ my $path = "/test/blahblah\@example.com/t.mbox.gz";
+ my $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 501 /, "search not-yet-enabled");
+ my $cmd = ['-index', $ibx->{inboxdir}, '--max-size=2k'];
+ print $cfgfh "\tindexlevel = basic\n" or BAIL_OUT $!;
+ $cfgfh->flush or BAIL_OUT $!;
+ my $opt = { 2 => \(my $err) };
+ my $indexed = run_script($cmd, undef, $opt);
+ if ($indexed) {
+ $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 200 /, "search returned mbox");
+ my $in = $res->{body};
+ my $out;
+ gunzip(\$in => \$out);
+ like($out, qr/^From /m, "From lines in mbox");
+ $res = cgi_run('/test/toobig@example.com/');
+ like($res->{head}, qr/^Status: 300 /,
+ 'did not index or return >max-size message');
+ like($err, qr/skipping [a-f0-9]{40,}/,
+ 'warned about skipping large OID');
+ } else {
+ like($res->{head}, qr/^Status: 501 /, "search not available");
+ skip('DBD::SQLite not available', 7); # (4 - 1) above, 4 below
+ }
+ require_mods('XML::TreePP', 4);
+ $path = "/test/blahblah\@example.com/t.atom";
+ $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 200 /, "atom returned 200");
+ like($res->{head}, qr!^Content-Type: application/atom\+xml!m,
+ "search returned atom");
+ my $t = XML::TreePP->new->parse($res->{body});
+ is(scalar @{$t->{feed}->{entry}}, 3, "parsed three entries");
+ like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
+ 'looks like an an Atom feed');