[Catalyst-commits] r9781 - Catalyst-Runtime/5.80/trunk/t

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Apr 21 21:38:02 GMT 2009


Author: t0m
Date: 2009-04-21 22:38:02 +0100 (Tue, 21 Apr 2009)
New Revision: 9781

Added:
   Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
Log:
Tests for kds fail. Comments indicate other fail?

Added: Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_setup_log.t	2009-04-21 21:38:02 UTC (rev 9781)
@@ -0,0 +1,82 @@
+use strict;
+use warnings;
+
+use Test::More tests => 24;
+use Test::Exception;
+
+use Catalyst ();
+
+sub mock_app {
+    my $name = shift;
+    my $meta = Moose->init_meta( for_class => $name );
+    $meta->superclasses('Catalyst');
+    return $meta->name;
+}
+
+sub test_log_object {
+    my ($log, %expected) = @_;
+    foreach my $level (keys %expected) {
+        my $method_name = "is_$level";
+        if ($expected{$level}) {
+            ok( $log->$method_name(), "Level $level on" );
+        }
+        else {
+            ok( !$log->$method_name(), "Level $level off" );
+        }
+    }
+}
+
+local %ENV; # Ensure blank or someone, somewhere will fail..
+
+{
+    my $app = mock_app('TestLogAppParseLevels');
+    $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?
+        error => 1,
+        warn => 1,
+        info => 0,
+        debug => 0,
+    );
+}
+{
+    local %ENV = ( CATALYST_DEBUG => 1 );
+    my $app = mock_app('TestLogAppDebugEnvSet');
+    $app->setup_log('');
+    ok $app->debug, 'In debug mode';
+    test_log_object($app->log,
+        fatal => 1, # Note, log levels _are_ seemingly additive if debug is on.
+        error => 1, # CRACK - someone has been smoking it.
+        warn => 1,
+        info => 1,
+        debug => 1,
+    );
+}
+{
+    local %ENV = ( CATALYST_DEBUG => 0 );
+    my $app = mock_app('TestLogAppDebugEnvUnset');
+    $app->setup_log('');
+    ok !$app->debug, 'Not In debug mode';
+    test_log_object($app->log,
+        fatal => 0,
+        error => 0,
+        warn => 0,
+        info => 0,
+        debug => 0,
+    );
+}
+{
+    my $app = mock_app('TestLogAppDebugOnly');
+    $app->setup_log('debug');
+    ok $app->debug, 'In debug mode';
+    test_log_object($app->log,
+        fatal => 0,
+        error => 0,
+        warn => 0,
+        info => 0,
+        debug => 1,
+    );
+}




More information about the Catalyst-commits mailing list