X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F01app.t;h=d41e8893d0a47a906bccb871391a7c7a2925575f;hb=9c9a9815a8161c91dc9a31d761e1b748d743e325;hp=267e80537e5944cf2653a58b860018143f66ac5b;hpb=f2338f4f3142b64ccd1994ddb3565ee34b3b7a5f;p=catagits%2FGitalist.git diff --git a/t/01app.t b/t/01app.t index 267e805..d41e889 100644 --- a/t/01app.t +++ b/t/01app.t @@ -1,47 +1,76 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More qw/no_plan/; +use Test::More; +use FindBin qw/$Bin/; +use lib "$Bin/lib"; -BEGIN { use_ok 'Catalyst::Test', 'Gitalist' } - -# Full tests are only run if the APP_TEST env var is set. -# This is needed to load the test configuration. -diag("*** SKIPPING app tests. -*** Set APP_TEST for the tests to run fully") if !$ENV{APP_TEST}; -SKIP: { - skip "Set APP_TEST for the tests to run fully", - 1 if !$ENV{APP_TEST}; +BEGIN { + $ENV{GITALIST_CONFIG} = $Bin; + $ENV{GITALIST_REPO_DIR} = ''; + use_ok 'Catalyst::Test', 'Gitalist'; +} +use TestGitalist; - ok( request('/')->is_success, 'Request should succeed' ); +for my $p ('', qw{ + repo1 nodescription bare.git opml search + fragment/collectionofrepositories +}) { + my $path = '/' . $p; + ok( request($path)->is_success, "$path should succeed"); +} +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 + local *test = curry_test_uri('fragment/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/shortlog/dir1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1'); +} +{ # URI tests for repo1 - use Data::Dumper; - my $test_repo1 = curry_test_uri('repo1'); - &$test_repo1('/summary'); - &$test_repo1('/shortlog'); - &$test_repo1('/log'); - &$test_repo1('/commit'); - &$test_repo1('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); - &$test_repo1('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); -# &$test_repo1('/', 'a=blob;f=file1'); + local *test = curry_test_uri('repo1'); + test(''); + test('search'); + test('shortlog'); + test('log'); + test('reflog'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patch'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/patches/2'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/raw/file1'); + test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1'); -} # Close APP_TEST skip + TODO: { + local $TODO = "FIXME"; + test('search', 'type=commit&text=added'); -sub test_uri { - my ($p, $uri, $qs) = @_; - $qs ||= ''; - my $request = "$uri?p=repo1;$qs"; - warn("request: $request"); - my $response = request($request); - ok($response->is_success, "ok $p - $uri"); + # 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 = shift; - test_uri($p, $uri); - }; -}; +done_testing;