Merge and cleanup
Tomas Doran [Sat, 7 Nov 2009 19:36:37 +0000 (19:36 +0000)]
1  2 
t/01app.t

diff --cc t/01app.t
+++ b/t/01app.t
@@@ -1,22 -1,47 +1,50 @@@
  #!/usr/bin/env perl
  use strict;
  use warnings;
 -use Test::More qw/no_plan/;
 +use Test::More;
 +use FindBin qw/$Bin/;
  
 -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;
 +    use_ok 'Catalyst::Test', 'Gitalist'
 +}
  
 -  ok( request('/')->is_success, 'Request should succeed' );
 +ok( request('/')->is_success, 'Request should succeed' );
 +for my $p (qw/ bare.git repo1 nodescription /) {
 +    my $path = '/summary?p=' . $p;
 +    ok( request($path)->is_success, "$path should succeed");
 +}
  
 +is request('/summary?p=DoesNotExist')->code, 404,
 +    '/summary?p=DoesNotExist 404s';
++{
+   # 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('/summary');
++  test('/shortlog');
++  test('/log');
++  test('/commit');
++  test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
++  test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
++#  $test_repo1->('/', 'a=blob;f=file1');
++}
  
 -} # Close APP_TEST skip
 +done_testing;
  
+ 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");
+ }
+ sub curry_test_uri {
+     my $p = shift;
+     sub {
+         my $uri = shift;
+         test_uri($p, $uri);
+     };
+ };