Cpanel-iContact-Provider-IRC.t 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use strict;
  2. use warnings;
  3. use Cwd qw{abs_path};
  4. use File::Basename qw{dirname};
  5. use lib abs_path( dirname(__FILE__) . "/../lib" );
  6. use Test::More 'tests' => 5;
  7. use Test::Fatal;
  8. use Bot::BasicBot ();
  9. is( exception { require Cpanel::iContact::Provider::IRC; }, undef, 'Module at least compiles' );
  10. isa_ok( my $bot = Cpanel::iContact::Provider::IRC->new(), "Cpanel::iContact::Provider::IRC" );
  11. my $sent;
  12. {
  13. no warnings qw{redefine once};
  14. local *Bot::BasicBot::new = sub { return bless {}, "Bot::BasicBot"; };
  15. local *Bot::BasicBot::say = sub { return ( 'ok', "Assumed Success" ); };
  16. local *Bot::BasicBot::shutdown = sub { return; };
  17. is( exception { $sent = $bot->send(); }, undef, 'send() did not throw' );
  18. }
  19. ok( $sent, "...and the message appears to have actually sent." );
  20. SKIP: {
  21. my $conf_file = abs_path( dirname(__FILE__) . "/../.irctestrc" );
  22. skip "Skipping functional testing, needful not supplied", 1 if !$ENV{'AUTHOR_TESTS'} || !-f $conf_file;
  23. my $test_conf = { Config::Simple->import_from($conf_file)->vars() };
  24. my %args = (
  25. 'destination' => $test_conf->{'XMPPUSERNAME'},
  26. 'subject' => 'My Super cool test notification',
  27. 'content' => "This is a test of Cpanel::iContact::Provider::IRC. Please Ignore",
  28. );
  29. {
  30. no warnings qw{redefine once};
  31. local *Cpanel::iContact::Provider::IRC::new = sub {
  32. return bless {
  33. 'contact' => $test_conf,
  34. }, $_[0];
  35. };
  36. my $spammer = Cpanel::iContact::Provider::XMPP->new();
  37. is( exception { $spammer->_send(%args) }, undef, "Didn't fail to send notification using full functional test" );
  38. }
  39. }
  40. # TODO error paths