Commit | Line | Data |
89de6a33 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
a38862e5 |
4 | use Test::More; |
5 | use FindBin qw/$Bin/; |
89de6a33 |
6 | |
a38862e5 |
7 | BEGIN { |
8 | $ENV{GITALIST_CONFIG} = $Bin; |
eb7978f3 |
9 | $ENV{GITALIST_REPO_DIR} = ''; |
1819cb18 |
10 | use_ok 'Catalyst::Test', 'Gitalist'; |
a38862e5 |
11 | } |
28e35997 |
12 | |
840edca5 |
13 | for my $p ('', qw/ repo1 nodescription bare.git opml /) { |
2a172f65 |
14 | my $path = '/' . $p; |
5fd1f586 |
15 | ok( request($path)->is_success, "$path should succeed"); |
16 | } |
28e35997 |
17 | |
2a172f65 |
18 | my $response = request('/DoesNotExist'); |
82bc0f05 |
19 | is $response->code, 404, 'invalid repository 404s'; |
20 | like $response->content, qr/Page not found/, 'invalid repository handled correctly'; |
b4439022 |
21 | |
b4439022 |
22 | |
f9466a6c |
23 | { |
f2338f4f |
24 | # URI tests for repo1 |
f9466a6c |
25 | local *test = curry_test_uri('repo1'); |
50df06b8 |
26 | test(''); |
27 | test('shortlog'); |
28 | test('log'); |
29 | test('reflog'); |
30 | test('commit'); |
31 | TODO: { |
32 | local $TODO = "FIXME"; |
33 | test('commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
34 | test('tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
35 | test('search', 'type=commit&text=added'); |
36 | test('blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
37 | test('blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
38 | test('patch'); |
39 | test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); |
40 | test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
41 | test('patches'); |
42 | test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); |
43 | test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
44 | } |
f9466a6c |
45 | } |
e8b87f6b |
46 | |
a38862e5 |
47 | done_testing; |
48 | |
f2338f4f |
49 | sub test_uri { |
50df06b8 |
50 | my ($uri, $qs) = @_; |
f2338f4f |
51 | $qs ||= ''; |
50df06b8 |
52 | my $request = "/$uri"; |
53 | $request .= "?$qs" if defined $qs; |
f2338f4f |
54 | my $response = request($request); |
50df06b8 |
55 | ok($response->is_success, "ok $uri - $qs"); |
56 | return $response; |
f2338f4f |
57 | } |
58 | |
59 | sub curry_test_uri { |
50df06b8 |
60 | my $prefix = shift; |
61 | my $to_curry = shift || \&test_uri; |
f2338f4f |
62 | sub { |
50df06b8 |
63 | my $uri = shift; |
64 | $to_curry->("$prefix/$uri", @_); |
f2338f4f |
65 | }; |
50df06b8 |
66 | } |