Fix a load of links, and fix blob/blame/raw/history actions to (semi) work + tests
[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;
eb7978f3 9 $ENV{GITALIST_REPO_DIR} = '';
1819cb18 10 use_ok 'Catalyst::Test', 'Gitalist';
a38862e5 11}
28e35997 12
840edca5 13for 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 18my $response = request('/DoesNotExist');
82bc0f05 19is $response->code, 404, 'invalid repository 404s';
20like $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');
a349e797 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');
ca06a177 36 test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1');
37 test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1');
38 test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/raw/file1');
39 test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1');
40
50df06b8 41 TODO: {
42 local $TODO = "FIXME";
a349e797 43 test('search', 'type=commit&text=added');
44
a349e797 45 # FIXME - What's the difference here?
46 #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e');
47 #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
48 #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e');
49 #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
50df06b8 50 }
f9466a6c 51}
e8b87f6b 52
a38862e5 53done_testing;
54
f2338f4f 55sub test_uri {
50df06b8 56 my ($uri, $qs) = @_;
f2338f4f 57 $qs ||= '';
50df06b8 58 my $request = "/$uri";
59 $request .= "?$qs" if defined $qs;
f2338f4f 60 my $response = request($request);
50df06b8 61 ok($response->is_success, "ok $uri - $qs");
62 return $response;
f2338f4f 63}
64
65sub curry_test_uri {
50df06b8 66 my $prefix = shift;
67 my $to_curry = shift || \&test_uri;
f2338f4f 68 sub {
50df06b8 69 my $uri = shift;
70 $to_curry->("$prefix/$uri", @_);
f2338f4f 71 };
50df06b8 72}