Переглянути джерело

Add TODO, start to work on tests

Andy Baugh 8 роки тому
батько
коміт
22e5b8f2bb

+ 2 - 1
Cpanel/iContact/Provider/XMPP.pm

@@ -65,7 +65,8 @@ sub _send {
     my $status;
     {
         local $SIG{'ALRM'} = sub { die "Error: XMPP Connection failed: Timeout while attempting connection\n" };
-        alarm 10;
+        $self->{'_xmpp_alarm'} ||= 10; # For tests
+        alarm $self->{'_xmpp_alarm'};
         $status = $xmpp_conn->Connect(
             'hostname'      => $srvr_name,
             'componentname' => $cmpt_name,

+ 15 - 1
README.md

@@ -1,4 +1,18 @@
 # iContact-cPanel-Plugins
 Extra "Contact Manager" Providers for cPanel and WHM
 
-Coming Soon!
+Still somewhat WIP, for now only has 'alpha' quality XMPP provider
+Plans for the future in TODO
+
+Steps 4 GreatSuccess:
+* Run the Tests
+    make test
+
+* Install the Modules
+    make install
+
+* Go to WHM >> Basic Setup and configure the provider options
+* Go to WHM >> Contact Manager and make sure it is set up to spam you mercilessly
+* Do something to trigger notifications from cPanel & WHM
+
+Enjoy!

+ 11 - 0
TODO

@@ -0,0 +1,11 @@
+XMPP provider:
+* Add Unit Tests
+* Add Functional Tests
+* Send to rooms? I haven't tried that
+* Register the user? Haven't tried that.
+
+Other Providers:
+* IRC
+* Discord
+* Slack (if I can't figure out how to get that mainlined with a good ext auth integration... their oauth is a pain)
+* ... Whatever else is hanging out on the feature site that sounds interesting

+ 6 - 0
t/Cpanel-iContact-Provider-Schema-XMPP.t

@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+
+use Test::More 'tests' => 1;
+
+pass();

+ 34 - 0
t/Cpanel-iContact-Provider-XMPP.t

@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+
+use Test::More 'tests' => 5;
+use Test::Fatal;
+
+# ================================
+# MOCK ME BABY ALL NIGHT LONG
+# ================================
+package Cpanel::iContact::Provider;
+
+sub new {
+    my $class = shift;
+    my $self = {
+        'widdly' => 'waa',
+    };
+    return bless $self, $class;
+}
+
+is( exception { require Cpanel::iContact::Provider; }, undef, 'Module at least compiles' );
+isa_ok( my $xmpp = Cpanel::iContact::Provider::XMPP->new(), "Cpanel::iContact::Provider::XMPP" );
+my $sent;
+{
+    no warnings qw{redefine once};
+    *Net::XMPP::Client::Connect     = sub { return 1; };
+    *Net::XMPP::Client::AuthSend    = sub { return ( 'ok', "Assumed Success" ); };
+    *Net::XMPP::Client::MessageSend = sub { return; };
+    *Net::XMPP::Client::Disconnect  = sub { return; };
+    is( exception { $sent = $xmpp->send(); }, undef, 'send() did not die' );
+}
+ok( $sent, "...and the message appears to have actually sent." );
+
+# TODO more error paths
+#isnt( exception { $xmpp->send(); }, undef, "We blew up when we timed out on connect" );