Sort the tests out..
[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     $ENV{GITALIST_REPO_DIR} = '';
10     use_ok 'Catalyst::Test', 'Gitalist';
11 }
12
13 for my $p ('', qw/ repo1 nodescription bare.git opml /) {
14     my $path = '/' . $p;
15     ok( request($path)->is_success, "$path should succeed");
16 }
17
18 my $response = request('/DoesNotExist');
19 is $response->code, 404, 'invalid repository 404s';
20 like $response->content, qr/Page not found/, 'invalid repository handled correctly';
21
22
23 {
24   # URI tests for repo1
25   local *test = curry_test_uri('repo1');
26   test('');
27   test('shortlog');
28   test('log');
29   test('reflog');
30   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
31   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree');
32   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff');
33   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patch');
34   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/1');
35   test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/2');
36   
37   TODO: {
38       local $TODO = "FIXME";
39       test('search', 'type=commit&text=added');
40
41
42       test('blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
43
44       # FIXME - What's the difference here?
45       #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e');
46       #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
47       #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e');
48       #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
49   }
50 }
51
52 done_testing;
53
54 sub test_uri {
55     my ($uri, $qs) = @_;
56     $qs ||= '';
57     my $request = "/$uri"; 
58     $request .= "?$qs" if defined $qs;
59     my $response = request($request);
60     ok($response->is_success, "ok $uri - $qs");
61     return $response;
62 }
63
64 sub curry_test_uri {
65     my $prefix = shift;
66     my $to_curry = shift || \&test_uri;
67     sub {
68         my $uri = shift;
69         $to_curry->("$prefix/$uri", @_);
70     };
71 }