PGXN-Site

 view release on metacpan or  search on metacpan

t/router.t  view on Meta::CPAN

        'The body should have the invalid in param error';
};

# Test /recent.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/recent', '/recent/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1>Recent Releases</h1>}, 'The body should look correct';
    }
};

# Test /feedback.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/feedback', '/feedback/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1 id="feedback">Feedback</h1>}, 'The body should look correct';
    }
};

# Test /about.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/about', '/about/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1 id="aboutpgxn">About PGXN</h1>}, 'The body should look correct';
    }
};

# Test /donors.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/donors', '/donors/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1>Donors</h1>}, 'The body should look correct';
    }
};

# Test /faq.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/faq', '/faq/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1 id="frequentlyaskedquestions">Frequently Asked Questions</h1>},
            'The body should look correct';
    }
};

# Test /mirroring.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/mirroring', '/mirroring/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        like $res->content, qr{\Q<h1 id="mirroringpgxn">Mirroring PGXN</h1>},
            'The body should look correct';
    }
};

# Test /meta/spec.txt.
test_psgi $app => sub {
    my $cb = shift;
    my $uri = '/meta/spec.txt';
    ok my $res = $cb->(GET $uri), "Fetch $uri";
    is $res->code, 200, 'Should get 200 response';
    no utf8;
    like $res->content,
        qr{PGXN Meta Spec - The PGXN distribution metadatå specification$}m,
        'The body should look correct';
};

# Test /spec.
test_psgi $app => sub {
    my $cb = shift;
    for my $uri ('/spec', '/spec/') {
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        is $res->code, 200, 'Should get 200 response';
        no utf8;
        like $res->content,
            qr{<p>PGXN Meta Spec - The PGXN distribution metadatå specification</p>$}m,
                'The body should look correct';
    }
};

# Test legacy URLs.
test_psgi $app => sub {
    my $cb = shift;
    for my $spec (
        [ contact      => '/feedback/'  ],
        [ contributors => '/donors/'    ],
        [ mirroring    => '/mirroring/' ],
        [ faq          => '/faq/'       ],
        [ 'meta/spec'  => '/spec/'      ],
    ) {
        my $uri = "/$spec->[0].html";
        ok my $res = $cb->(GET $uri), "Fetch $uri";
        ok !$res->is_success, 'Should not be a success';
        is $res->code, 301, 'Should get 301 response';
        is $res->headers->header('location'), $spec->[1],
            "Should redirect to $spec->[1]";
    }
};

# Test /error.
my $err_output;
my $err_app = sub {
    my $env = shift;
    open my $errfh, '>', \$err_output;
    $env->{'psgix.errordocument.PATH_INFO'} = '/what';
    $env->{'psgix.errordocument.SCRIPT_NAME'} = '';
    $env->{'psgix.errordocument.SCRIPT_NAME'} = '';
    $env->{'psgix.errordocument.HTTP_HOST'} = 'localhost';
    $env->{'plack.stacktrace.text'} = 'This is the trace';
    $env->{'psgi.errors'} = $errfh;
    $app->($env);



( run in 1.069 second using v1.01-cache-2.11-cpan-c221a9de4ec )