]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/plack.t
www: implement hybrid flat+thread conversation view
[public-inbox.git] / t / plack.t
index c8dd7bfe818b60e86c58eaf4a05debded8b060de..209c6f90bc285c0819ddeaf64ef9483a4a680ee7 100644 (file)
--- a/t/plack.t
+++ b/t/plack.t
@@ -30,6 +30,8 @@ foreach my $mod (@mods) { use_ok $mod; }
        my %cfg = (
                "$cfgpfx.address" => $addr,
                "$cfgpfx.mainrepo" => $maindir,
+               "$cfgpfx.url" => 'http://example.com/test/',
+               "$cfgpfx.newsgroup" => 'inbox.test',
        );
        while (my ($k,$v) = each %cfg) {
                is(0, system(qw(git config --file), $pi_config, $k, $v),
@@ -60,6 +62,27 @@ EOF
                require $psgi;
        };
 
+       test_psgi($app, sub {
+               my ($cb) = @_;
+               foreach my $u (qw(robots.txt favicon.ico .well-known/foo)) {
+                       my $res = $cb->(GET("http://example.com/$u"));
+                       is($res->code, 404, "$u is missing");
+               }
+       });
+
+       # redirect with newsgroup
+       test_psgi($app, sub {
+               my ($cb) = @_;
+               my $from = 'http://example.com/inbox.test';
+               my $to = 'http://example.com/test/';
+               my $res = $cb->(GET($from));
+               is($res->code, 301, 'newsgroup name is permanent redirect');
+               is($to, $res->header('Location'), 'redirect location matches');
+               $from .= '/';
+               is($res->code, 301, 'newsgroup name/ is permanent redirect');
+               is($to, $res->header('Location'), 'redirect location matches');
+       });
+
        # redirect with trailing /
        test_psgi($app, sub {
                my ($cb) = @_;
@@ -78,7 +101,7 @@ EOF
                        my $res = $cb->(GET($u));
                        is(301, $res->code, "redirect for missing /");
                        my $location = $res->header('Location');
-                       like($location, qr!/\Q$t\E/#u\z!,
+                       like($location, qr!/t/#u\z!,
                                'redirected with missing /');
                });
        }