Sfoglia il codice sorgente

Finish happy path unit test for main xmpp function

Also add cover db files to gitignore
Andy Baugh 8 anni fa
parent
commit
ff31484470

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
 *.bak
 *.swp
+cover_db

+ 2 - 2
Makefile

@@ -1,7 +1,7 @@
 install:
 	[ -d /var/cpanel/perl/Cpanel/iContact/Provider/Schema ] || mkdir -p /var/cpanel/perl/Cpanel/iContact/Provider/Schema/
-	cp -f Cpanel/iContact/Provider/Schema/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/
-	cp -f Cpanel/iContact/Provider/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/
+	cp -f lib/Cpanel/iContact/Provider/Schema/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/Schema/
+	cp -f lib/Cpanel/iContact/Provider/*.pm /var/cpanel/perl/Cpanel/iContact/Provider/
 
 test:
 	prove t/*.t

+ 1 - 0
README.md

@@ -5,6 +5,7 @@ Still somewhat WIP, for now only has 'alpha' quality XMPP provider
 Plans for the future in TODO
 
 Steps 4 GreatSuccess:
+* Clone this repo with git onto a cPanel host of at least 11.62+
 * Run the Tests
     make test
 

+ 29 - 0
lib/Cpanel/iContact/Provider.pm

@@ -0,0 +1,29 @@
+# ================================
+# MOCK ME BABY ALL NIGHT LONG
+# ================================
+package Cpanel::iContact::Provider;
+
+use strict;
+use warnings;
+
+sub new {
+    my $class = shift;
+    my $text_body = 'HOLY CRAP THE AUTO-LAYOFF THING TRIGGERED';
+    my $self = {
+        'contact' => {
+            'XMPPUSERNAME'  => 'mr_t@a-team.gov',
+            'XMPPPASSWORD'  => 'bjBarracus#1',
+            'XMPPUSETLS'    => 1,
+            'XMPPTLSVERIFY' => 1,
+            'XMPPCOMPONENTNAME' => 'jibber.jabber.org'
+        },
+        'args' => {
+            'subject'   => 'cPanel on Drugs',
+            'text_body' => \$text_body, #nutty, I know
+            'to'        => [ 'cronspam@dev.null' ],
+        }
+    };
+    return bless $self, $class;
+}
+
+1;

+ 0 - 0
Cpanel/iContact/Provider/Schema/XMPP.pm → lib/Cpanel/iContact/Provider/Schema/XMPP.pm


+ 1 - 1
Cpanel/iContact/Provider/XMPP.pm → lib/Cpanel/iContact/Provider/XMPP.pm

@@ -26,7 +26,7 @@ sub send {
                 'destination' => $destination,
                 'subject' => $subject,
                 'content' => $body
-            ) || die "Sending to $destination failed: " . $self->_last_error();
+            );
         };
         push( @errs, $@ ) if $@;
     }

+ 7 - 16
t/Cpanel-iContact-Provider-XMPP.t

@@ -1,23 +1,14 @@
 use strict;
 use warnings;
 
-use Test::More 'tests' => 5;
-use Test::Fatal;
-
-# ================================
-# MOCK ME BABY ALL NIGHT LONG
-# ================================
-package Cpanel::iContact::Provider;
+use Cwd qw{abs_path};
+use File::Basename qw{dirname};
+use lib abs_path( dirname(__FILE__) . "/../lib" );
 
-sub new {
-    my $class = shift;
-    my $self = {
-        'widdly' => 'waa',
-    };
-    return bless $self, $class;
-}
+use Test::More 'tests' => 4;
+use Test::Fatal;
 
-is( exception { require Cpanel::iContact::Provider; }, undef, 'Module at least compiles' );
+is( exception { require Cpanel::iContact::Provider::XMPP; }, undef, 'Module at least compiles' );
 isa_ok( my $xmpp = Cpanel::iContact::Provider::XMPP->new(), "Cpanel::iContact::Provider::XMPP" );
 my $sent;
 {
@@ -30,5 +21,5 @@ my $sent;
 }
 ok( $sent, "...and the message appears to have actually sent." );
 
-# TODO more error paths
+# TODO error paths
 #isnt( exception { $xmpp->send(); }, undef, "We blew up when we timed out on connect" );