Migrated blob to new model, + fixes for some legacy URI fails.
[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('/reflog');
28   test('/commit');
29   test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
30   test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
31   test('/search', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818&f=&type=commit&text=added');
32   test('/blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
33   test('/blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
34 }
35
36 done_testing;
37
38 sub test_uri {
39     my ($p, $uri, $qs) = @_;
40     $qs ||= '';
41     my $request = "$uri?p=repo1;$qs";
42     my $response = request($request);
43     ok($response->is_success, "ok $p - $uri - $qs");
44 }
45
46 sub curry_test_uri {
47     my $p = shift;
48     sub {
49         my ($uri, $qs) = @_;
50         test_uri($p, $uri, $qs);
51     };
52 };