]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/psgi_v2.t
make Plack optional for non-WWW and non-httpd users
[public-inbox.git] / t / psgi_v2.t
index 1163e2bf89f73c9bd400b23f5fbe2d275086ce94..2ecd7458e48eee28467194faa01f14161449397e 100644 (file)
@@ -3,19 +3,15 @@
 use strict;
 use warnings;
 use Test::More;
-require './t/common.perl';
+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 = {
@@ -155,9 +151,19 @@ test_psgi(sub { $www->call(@_) }, sub {
        is($res->code, 200, 'success with threaded search');
        my $raw = $res->content;
        ok($raw =~ s/\A.*>Results 1-3 of 3\b//s, 'got all results');
-       my @over = ($raw =~ m/\d{4}-\d+-\d+\s+\d+:\d+ (.+)$/gm);
+       my @over = ($raw =~ m/\d{4}-\d+-\d+\s+\d+:\d+ +(?:\d+\% )?(.+)$/gm);
        is_deeply(\@over, [ '<a', '` <a', '` <a' ], 'threaded messages show up');
 
+       $res = $cb->(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;