convert test checking encoding set in config to checking encoding set by plugin
[catagits/Catalyst-Runtime.git] / t / optional_stress.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 BEGIN {
6     plan skip_all => 'set TEST_STRESS to enable this test'
7       unless $ENV{TEST_STRESS};
8 }
9
10 use FindBin;
11 use lib "$FindBin::Bin/lib";
12 use Catalyst::Test 'TestApp';
13
14 our ( $iters, $tests );
15
16 BEGIN {
17     use JSON::MaybeXS qw(decode_json);
18
19     my $test_data = do {
20       open my $fh, '<:raw', "$FindBin::Bin/optional_stress.json" or die "$!";
21       local $/;
22       <$fh>;
23     };
24
25     $iters = $ENV{TEST_STRESS} || 10;
26     $tests = decode_json($test_data);
27
28     my $total_tests = 0;
29     map { $total_tests += scalar @{ $tests->{$_} } } keys %{$tests};
30     plan tests => $iters * $total_tests;
31 }
32
33 for ( 1 .. $iters ) {
34     run_tests();
35 }
36
37 sub run_tests {
38     foreach my $test_group ( keys %{$tests} ) {
39         foreach my $test ( @{ $tests->{$test_group} } ) {
40             ok( request($test), $test_group . ' - ' . $test );
41         }
42     }
43 }