Merge branch 'master' into model-reorg
[catagits/Gitalist.git] / t / 01app.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5 use FindBin qw/$Bin/;
6
7 BEGIN {
8     $ENV{GITALIST_CONFIG} = $Bin;
9     use_ok 'Catalyst::Test', 'Gitalist'
10 }
11
12 ok( request('/')->is_success, 'Request should succeed' );
13
14 for my $p (qw/ repo1 nodescription /) {
15     my $path = '/summary?p=' . $p;
16     ok( request($path)->is_success, "$path should succeed");
17 }
18
19 is request('/summary?p=DoesNotExist')->code, 404,
20     '/summary?p=DoesNotExist 404s';
21 {
22   # URI tests for repo1
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');
30
31   # legacy URIs
32   test('/', 'a=summary');
33   test('/', 'a=heads');
34   test('/', 'a=shortlog');
35   test('/', 'a=log');
36   test('/', 'a=commit');
37   test('/', 'a=commitdiff');
38   test('/', 'a=tree');
39 #  $test_repo1->('/', 'a=blob;f=file1');
40 }
41
42 done_testing;
43
44 sub test_uri {
45     my ($p, $uri, $qs) = @_;
46     $qs ||= '';
47     my $request = "$uri?p=repo1;$qs";
48     warn("request: $request");
49     my $response = request($request);
50     ok($response->is_success, "ok $p - $uri");
51 }
52
53 sub curry_test_uri {
54     my $p = shift;
55     sub {
56         my ($uri, $qs) = @_;
57         test_uri($p, $uri, $qs);
58     };
59 };