X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fpsgi_v2.t;h=fc825acf621936c13b323e673d069fc268bf21dd;hb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;hp=101765168d44068b2843a9d4a2345399dbddf5e1;hpb=f6f0cfb7f3b673f05a95e8c9c3bc7d31580feadc;p=public-inbox.git diff --git a/t/psgi_v2.t b/t/psgi_v2.t index 10176516..fc825acf 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,15 +7,11 @@ use PublicInbox::TestCommon; require_git(2.6); use PublicInbox::MIME; use PublicInbox::Config; -use PublicInbox::WWW; use PublicInbox::MID qw(mids); -my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test - URI::Escape Plack::Builder); -foreach my $mod (@mods) { - eval "require $mod"; - plan skip_all => "$mod missing for psgi_v2_dupes.t" if $@; -} -use_ok($_) for @mods; +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 = { @@ -62,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'); @@ -158,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::Feed), 2); + $raw = $res->content; + my $p = XML::Feed->parse(\$raw); + is($p->format, "Atom", "parsed atom feed"); + is(scalar $p->entries, 3, "parsed three entries"); + }; + local $SIG{__WARN__} = 'DEFAULT'; $res = $cb->(GET('/v2test/a-mid@b/')); $raw = $res->content;