Comprehensive legacy URI tests from spidering gitweb.cgi.
[catagits/Gitalist.git] / t / 01app.t
CommitLineData
89de6a33 1#!/usr/bin/env perl
2use strict;
3use warnings;
a38862e5 4use Test::More;
5use FindBin qw/$Bin/;
89de6a33 6
a38862e5 7BEGIN {
8 $ENV{GITALIST_CONFIG} = $Bin;
9 use_ok 'Catalyst::Test', 'Gitalist'
10}
28e35997 11
89de6a33 12ok( request('/')->is_success, 'Request should succeed' );
f2338f4f 13
10af354d 14for my $p (qw/ repo1 nodescription /) {
5fd1f586 15 my $path = '/summary?p=' . $p;
16 ok( request($path)->is_success, "$path should succeed");
17}
28e35997 18
e8b87f6b 19is request('/summary?p=DoesNotExist')->code, 404,
20 '/summary?p=DoesNotExist 404s';
f9466a6c 21{
f2338f4f 22 # URI tests for repo1
f9466a6c 23 local *test = curry_test_uri('repo1');
24 test('/summary');
25 test('/shortlog');
26 test('/log');
27 test('/commit');
28 test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
29 test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
f9466a6c 30}
e8b87f6b 31
a38862e5 32done_testing;
33
f2338f4f 34sub test_uri {
35 my ($p, $uri, $qs) = @_;
36 $qs ||= '';
37 my $request = "$uri?p=repo1;$qs";
38 warn("request: $request");
39 my $response = request($request);
40 ok($response->is_success, "ok $p - $uri");
41}
42
43sub curry_test_uri {
44 my $p = shift;
45 sub {
46aab84d 46 my ($uri, $qs) = @_;
47 test_uri($p, $uri, $qs);
f2338f4f 48 };
49};