whitespace cleanup
[catagits/Catalyst-Runtime.git] / t / aggregate / live_priorities.t
CommitLineData
6ea96b03 1use strict;
2use warnings;
3
4use FindBin;
42da66a9 5use lib "$FindBin::Bin/../lib";
6ea96b03 6
9c1fc6d6 7use Test::More tests => 14;
6ea96b03 8use Catalyst::Test 'TestApp';
6ea96b03 9
10local $^W = 0;
11
12my $uri_base = 'http://localhost/priorities';
13my @tests = (
14
15 # Simple
6ea96b03 16 'Local vs. Path 1', { path => '/loc_vs_path1', expect => 'local' },
17 'Local vs. Path 2', { path => '/loc_vs_path2', expect => 'path' },
6ea96b03 18
19 # index
6ea96b03 20 'index vs. Local', { path => '/loc_vs_index', expect => 'index' },
6ea96b03 21 'index vs. Path', { path => '/path_vs_index', expect => 'index' },
0bd5f8a2 22
23 'multimethod zero', { path => '/multimethod', expect => 'zero' },
24 'multimethod one', { path => '/multimethod/1', expect => 'one 1' },
25 'multimethod two', { path => '/multimethod/1/2',
26 expect => 'two 1 2' },
6ea96b03 27);
28
29while ( @tests ) {
30
31 my $name = shift @tests;
32 my $data = shift @tests;
33
34 # Run tests for path with trailing slash and without
88e5a8b0 35 SKIP: for my $req_uri
36 (
6ea96b03 37 join( '' => $uri_base, $data->{ path } ), # Without trailing path
38 join( '' => $uri_base, $data->{ path }, '/' ), # With trailing path
39 ) {
40 my $end_slash = ( $req_uri =~ qr(/$) ? 1 : 0 );
41
88e5a8b0 42 # use slash_expect argument if URI ends with slash
6ea96b03 43 # and the slash_expect argument is defined
44 my $expect = $data->{ expect } || '';
45 if ( $end_slash and exists $data->{ slash_expect } ) {
46 $expect = $data->{ slash_expect };
47 }
48
49 # Call the URI on the TestApp
50 my $response = request( $req_uri );
51
52 # Leave expect out to see the result
53 unless ( $expect ) {
54 skip 'Nothing expected, winner is ' . $response->content, 1;
55 }
56
57 # Show error if response was no success
58 if ( not $response->is_success ) {
59 diag 'Error: ' . $response->headers->{ 'x-catalyst-error' };
60 }
61
62 # Test if content matches expectations.
63 # TODO This might flood the screen with the catalyst please-come-later
64 # page. So I don't know it is a good idea.
65 is( $response->content, $expect,
66 "$name: @{[ $data->{ expect } ]} wins"
67 . ( $end_slash ? ' (trailing slash)' : '' )
68 );
69 }
70}
71