X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=c4f808695b000110d84d69605f5e6e42a2437d2e;hb=6ebcec3add4d6aeff6e3b3eb019a404528c079ec;hp=a02b90fbee2ca8a55468fda116d64114b92d5207;hpb=cd8dd7b08fddc7c2b5f218c3fcaa5dca5f9ad945;p=public-inbox.git
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index a02b90fb..c4f80869 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2019 all contributors
+# Copyright (C) 2018-2020 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
@@ -7,11 +7,11 @@ use PublicInbox::TestCommon;
require_git(2.6);
use PublicInbox::MIME;
use PublicInbox::Config;
-use PublicInbox::WWW;
use PublicInbox::MID qw(mids);
require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
URI::Escape Plack::Builder));
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
+use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::V2Writable';
my ($inboxdir, $for_destroy) = tmpdir();
my $ibx = {
@@ -58,6 +58,9 @@ my $www = PublicInbox::WWW->new($config);
my ($res, $raw, @from_);
test_psgi(sub { $www->call(@_) }, sub {
my ($cb) = @_;
+ $res = $cb->(GET('/v2test/description'));
+ like($res->content, qr!\$INBOX_DIR/description missing!,
+ 'got v2 description missing message');
$res = $cb->(GET('/v2test/a-mid@b/raw'));
$raw = $res->content;
like($raw, qr/^hello world$/m, 'got first message');
@@ -154,6 +157,16 @@ test_psgi(sub { $www->call(@_) }, sub {
my @over = ($raw =~ m/\d{4}-\d+-\d+\s+\d+:\d+ +(?:\d+\% )?(.+)$/gm);
is_deeply(\@over, [ '(GET('/v2test/?q=m:a-mid@b&x=A'));
+ is($res->code, 200, 'success with Atom search');
+ SKIP: {
+ require_mods(qw(XML::TreePP), 2);
+ my $t = XML::TreePP->new->parse($res->content);
+ like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
+ 'looks like an an Atom feed');
+ is(scalar @{$t->{feed}->{entry}}, 3, 'parsed three entries');
+ };
+
local $SIG{__WARN__} = 'DEFAULT';
$res = $cb->(GET('/v2test/a-mid@b/'));
$raw = $res->content;
@@ -237,6 +250,8 @@ test_psgi(sub { $www->call(@_) }, sub {
is($old->content, 'old', 'got expected old content');
is($new->content, 'new', 'got expected new content');
}
+ $res = $cb->(GET('/v2test/?t=1970'.'01'.'01'.'000000'));
+ is($res->code, 404, '404 for out-of-range t= param');
});
done_testing();