X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01app.t;h=56f8799d62ce4baa0396b1df83d4942ad332f9de;hb=8f7296d0b564f052d4b17dddbd553dc355b04f88;hp=9ebc7a40ef225c6b7b2552d7915817cf25d08054;hpb=8bb7649bb9fb1347e1028d03b6eb6a21bcd115a7;p=catagits%2FGitalist.git diff --git a/t/01app.t b/t/01app.t index 9ebc7a4..56f8799 100644 --- a/t/01app.t +++ b/t/01app.t @@ -1,52 +1,65 @@ #!/usr/bin/env perl -use strict; -use warnings; -use Test::More; use FindBin qw/$Bin/; - BEGIN { - $ENV{GITALIST_CONFIG} = $Bin; - use_ok 'Catalyst::Test', 'Gitalist' + my $env = "$FindBin::Bin/../script/env"; + if (-r $env) { + do $env or die $@; + } } -ok( request('/')->is_success, 'Request should succeed' ); +use lib "$Bin/lib"; +use TestGitalist; -for my $p (qw/ repo1 nodescription /) { - my $path = '/summary?p=' . $p; +for my $p ('', qw{ + repo1 nodescription bare.git opml search + fragment/collectionofrepositories +}) { + my $path = '/' . $p; ok( request($path)->is_success, "$path should succeed"); } -is request('/summary?p=DoesNotExist')->code, 404, - '/summary?p=DoesNotExist 404s'; +my $response = request('/DoesNotExist'); +is $response->code, 404, 'invalid repository 404s'; +like $response->content, qr/Page not found/, 'invalid repository handled correctly'; + +# URI tests for repo1 +foreach my $test (map {curry_test_uri($_)} ('fragment/repo1', 'repo1') ) { + $test->(''); + $test->('shortlog'); + $test->('log'); + $test->('heads'); + $test->('tags'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree/dir1'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff/plain'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1'); + $test->('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1'); +} + { # URI tests for repo1 local *test = curry_test_uri('repo1'); - test('/summary'); - test('/shortlog'); - test('/log'); - test('/reflog'); - test('/commit'); - test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); - test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); - test('/search', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818&f=&type=commit&text=added'); - test('/blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); - test('/blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); -} + test('search'); -done_testing; + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patch'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/2'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/raw/file1'); -sub test_uri { - my ($p, $uri, $qs) = @_; - $qs ||= ''; - my $request = "$uri?p=repo1;$qs"; - my $response = request($request); - ok($response->is_success, "ok $p - $uri - $qs"); + TODO: { + local $TODO = "FIXME"; + test('search', 'type=commit&text=added'); + + # FIXME - What's the difference here? + #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); + #test('patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); + #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); + #test('patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); + } } -sub curry_test_uri { - my $p = shift; - sub { - my ($uri, $qs) = @_; - test_uri($p, $uri, $qs); - }; -}; +done_testing;