Implement 'patch' action.
[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;
9 use_ok 'Catalyst::Test', 'Gitalist'
10}
28e35997 11
89de6a33 12ok( request('/')->is_success, 'Request should succeed' );
f2338f4f 13
10af354d 14for my $p (qw/ repo1 nodescription /) {
5fd1f586 15 my $path = '/summary?p=' . $p;
16 ok( request($path)->is_success, "$path should succeed");
17}
28e35997 18
e8b87f6b 19is request('/summary?p=DoesNotExist')->code, 404,
20 '/summary?p=DoesNotExist 404s';
f9466a6c 21{
f2338f4f 22 # URI tests for repo1
f9466a6c 23 local *test = curry_test_uri('repo1');
24 test('/summary');
25 test('/shortlog');
26 test('/log');
d8abdf1c 27 test('/reflog');
f9466a6c 28 test('/commit');
29 test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
30 test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
d8abdf1c 31 test('/search', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818&f=&type=commit&text=added');
6cfcd548 32 test('/blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
8bb7649b 33 test('/blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
377bf360 34 test('/patch');
35 test('/patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e');
36 test('/patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac');
f9466a6c 37}
e8b87f6b 38
a38862e5 39done_testing;
40
f2338f4f 41sub test_uri {
42 my ($p, $uri, $qs) = @_;
43 $qs ||= '';
44 my $request = "$uri?p=repo1;$qs";
f2338f4f 45 my $response = request($request);
6cfcd548 46 ok($response->is_success, "ok $p - $uri - $qs");
f2338f4f 47}
48
49sub curry_test_uri {
50 my $p = shift;
51 sub {
46aab84d 52 my ($uri, $qs) = @_;
53 test_uri($p, $uri, $qs);
f2338f4f 54 };
55};