1c69c5b7da3460556d4d0b93b1ad2b3bfda0879f
[catagits/Gitalist.git] / t / 01app.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More qw/no_plan/;
5
6 BEGIN { use_ok 'Catalyst::Test', 'Gitalist' }
7
8 # Full tests are only run if the APP_TEST env var is set.
9 # This is needed to load the test configuration.
10 diag("*** SKIPPING app tests.
11 *** Set APP_TEST for the tests to run fully") if !$ENV{APP_TEST};
12 SKIP: {
13   skip "Set APP_TEST for the tests to run fully",
14     1 if !$ENV{APP_TEST};
15
16   ok( request('/')->is_success, 'Request should succeed' );
17
18
19   # URI tests for repo1
20   use Data::Dumper;
21   my $test_repo1 = curry_test_uri('repo1');
22   &$test_repo1('/summary');
23   &$test_repo1('/heads');
24   &$test_repo1('/shortlog');
25   &$test_repo1('/log');
26   &$test_repo1('/commit');
27   &$test_repo1('/commitdiff');
28   &$test_repo1('/tree');
29
30   # legacy URIs
31   &$test_repo1('/', 'a=summary');
32   &$test_repo1('/', 'a=heads');
33   &$test_repo1('/', 'a=shortlog');
34   &$test_repo1('/', 'a=log');
35   &$test_repo1('/', 'a=commit');
36   &$test_repo1('/', 'a=commitdiff');
37   &$test_repo1('/', 'a=tree');
38 #  &$test_repo1('/', 'a=blob;f=file1');
39
40 } # Close APP_TEST skip
41
42 sub test_uri {
43     my ($p, $uri, $qs) = @_;
44     $qs ||= '';
45     my $request = "$uri?p=repo1;$qs";
46     warn("request: $request");
47     my $response = request($request);
48     ok($response->is_success, "ok $p - $uri");
49 }
50
51 sub curry_test_uri {
52     my $p = shift;
53     sub {
54         my ($uri, $qs) = @_;
55         test_uri($p, $uri, $qs);
56     };
57 };