X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_core_setup_log.t;h=1406944eb032d450db7f56bc9c47d7f29419accb;hb=c68a3c90180235a2a464ce237a96fef79db468bf;hp=fe3e15ef8c037682d4d3a2808ff02dc1d168827a;hpb=d31581c60ff345e3fa71ca66bc83e826935b158b;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_core_setup_log.t b/t/unit_core_setup_log.t index fe3e15e..1406944 100644 --- a/t/unit_core_setup_log.t +++ b/t/unit_core_setup_log.t @@ -8,7 +8,7 @@ use Catalyst (); sub mock_app { my $name = shift; - warn("Setting up mock application: $name\n"); + print "Setting up mock application: $name\n"; my $meta = Moose->init_meta( for_class => $name ); $meta->superclasses('Catalyst'); return $meta->name; @@ -27,16 +27,19 @@ sub test_log_object { } } -local %ENV; # Ensure blank or someone, somewhere will fail.. +local %ENV = %ENV; + +# Remove all relevant env variables to avoid accidental fail +foreach my $name (grep { /^(CATALYST|TESTAPP)/ } keys %ENV) { + delete $ENV{$name}; +} { - my $app = mock_app('TestLogAppParseLevels'); + my $app = mock_app('TestAppParseLogLevels'); $app->setup_log('error,warn'); ok !$app->debug, 'Not in debug mode'; test_log_object($app->log, - fatal => 0, # WTF - I thought log levels were additive these days, - # or do I not understand the patch which pupported to make - # them so? + fatal => 1, error => 1, warn => 1, info => 0, @@ -44,55 +47,55 @@ local %ENV; # Ensure blank or someone, somewhere will fail.. ); } { - local %ENV = ( CATALYST_DEBUG => 1 ); - my $app = mock_app('TestLogAppDebugEnvSet'); + local %ENV = %ENV; + $ENV{CATALYST_DEBUG} = 1; + my $app = mock_app('TestAppLogDebugEnvSet'); $app->setup_log(''); ok $app->debug, 'In debug mode'; test_log_object($app->log, - fatal => 0, - error => 0, - warn => 0, - info => 0, + fatal => 1, + error => 1, + warn => 1, + info => 1, debug => 1, ); } { - local %ENV = ( CATALYST_DEBUG => 0 ); - my $app = mock_app('TestLogAppDebugEnvUnset'); + local %ENV = %ENV; + $ENV{CATALYST_DEBUG} = 0; + my $app = mock_app('TestAppLogDebugEnvUnset'); $app->setup_log('warn'); ok !$app->debug, 'Not In debug mode'; test_log_object($app->log, - fatal => 0, - error => 0, + fatal => 1, + error => 1, warn => 1, info => 0, debug => 0, ); } { - my $app = mock_app('TestLogAppEmptyString'); + my $app = mock_app('TestAppLogEmptyString'); $app->setup_log(''); ok !$app->debug, 'Not In debug mode'; - TODO: { - local $TODO = 'THis is insane'; - test_log_object($app->log, - fatal => 0, - error => 0, - warn => 0, - info => 0, - debug => 0, - ); - } + # Note that by default, you get _all_ the log levels turned on + test_log_object($app->log, + fatal => 1, + error => 1, + warn => 1, + info => 1, + debug => 1, + ); } { - my $app = mock_app('TestLogAppDebugOnly'); + my $app = mock_app('TestAppLogDebugOnly'); $app->setup_log('debug'); ok $app->debug, 'In debug mode'; test_log_object($app->log, - fatal => 0, - error => 0, - warn => 0, - info => 0, + fatal => 1, + error => 1, + warn => 1, + info => 1, debug => 1, ); }