Ver Fonte

Fix minor goofs with the test

Andy Baugh há 7 anos atrás
pai
commit
d1492696b7
2 ficheiros alterados com 25 adições e 24 exclusões
  1. 1 3
      lib/Cpanel/Exception.pm
  2. 24 21
      t/Cpanel-iContact-Provider-Slack.t

+ 1 - 3
lib/Cpanel/Exception.pm

@@ -1,7 +1,5 @@
 package Cpanel::Exception;
 
-use Test::More ();
-
-*create = &Test::More::explain;
+sub create { return [ @_ ] };
 
 1;

+ 24 - 21
t/Cpanel-iContact-Provider-Slack.t

@@ -29,29 +29,32 @@ subtest "Provider bits work as expected ('unit' test)" => sub {
     isa_ok( my $spammer = Cpanel::iContact::Provider::Slack->new(), "Cpanel::iContact::Provider::Slack" );
     is( exception { $spammer->send() }, undef, "send doesn't throw on GreatSuccess" );
     $resp_mocker->mock( 'success' => sub { return 0; }, 'status' => sub { return 500; }, 'reason' => sub { return 'ENOHUGS'; } );
-    isnt( exception { $spammer->send() }, undef, "send throws whenever anything goes wrong" );
+    my $ex;
+    is( $ex = exception { $spammer->send() }, undef, "send throws whenever anything goes wrong" ) || diag explain $ex;
 };
 
 subtest "Can send a message to somewhere (systems level/integration test)" => sub {
-    my $conf_file = abs_path( dirname(__FILE__) . "/../.slacktestrc" );
-    skip "Skipping functional testing, needful not supplied", 1 if !$ENV{'AUTHOR_TESTS'} || !-f $conf_file;
-    my $test_conf = { Config::Simple->import_from($conf_file)->vars() };
-    my $text_body = "This is a test of Cpanel::iContact::Provider::Slack. Please Ignore";
-    my %args = (
-        'to'        => [ $test_conf->{'CONTACTSLACK'} ],
-        'subject'   => 'My Super cool test notification',
-        'text_body' => \$text_body,
-    );
-
-    {
-        no warnings qw{redefine once};
-        local *Cpanel::iContact::Provider::Slack::new = sub {
-            return bless {
-                'contact' => $test_conf,
-                'args'    => \%args,
-            }, $_[0];
-        };
-        my $spammer = Cpanel::iContact::Provider::Slack->new();
-        is( exception { $spammer->send() }, undef, "Didn't fail to send notification using full functional test" );
+    SKIP: {
+        my $conf_file = abs_path( dirname(__FILE__) . "/../.slacktestrc" );
+        skip "Skipping functional testing, needful not supplied", 1 if !$ENV{'AUTHOR_TESTS'} || !-f $conf_file;
+        my $test_conf = { Config::Simple->import_from($conf_file)->vars() };
+        my $text_body = "This is a test of Cpanel::iContact::Provider::Slack. Please Ignore";
+        my %args = (
+            'to'        => [ $test_conf->{'CONTACTSLACK'} ],
+            'subject'   => 'My Super cool test notification',
+            'text_body' => \$text_body,
+        );
+
+        {
+            no warnings qw{redefine once};
+            local *Cpanel::iContact::Provider::Slack::new = sub {
+                return bless {
+                    'contact' => $test_conf,
+                    'args'    => \%args,
+                }, $_[0];
+            };
+            my $spammer = Cpanel::iContact::Provider::Slack->new();
+            is( exception { $spammer->send() }, undef, "Didn't fail to send notification using full functional test" );
+        }
     }
 };