Cpanel-iContact-Provider-IRC.t 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 IO::Socket::INET ();
  9. use IO::Socket::SSL ();
  10. use Config::Simple ();
  11. is( exception { require Cpanel::iContact::Provider::IRC; }, undef, 'Module at least compiles' );
  12. isa_ok( my $bot = Cpanel::iContact::Provider::IRC->new(), "Cpanel::iContact::Provider::IRC" );
  13. my $sent;
  14. {
  15. no warnings qw{redefine once};
  16. #is( exception { $sent = $bot->send(); }, undef, 'send() did not throw' );
  17. pass("wha");
  18. }
  19. #ok( $sent, "...and the message appears to have actually sent." );
  20. pass("dup");
  21. SKIP: {
  22. my $conf_file = abs_path( dirname(__FILE__) . "/../.irctestrc" );
  23. skip "Skipping functional testing, needful not supplied", 1 if !$ENV{'AUTHOR_TESTS'} || !-f $conf_file;
  24. my $test_conf = { Config::Simple->import_from($conf_file)->vars() };
  25. my %args = (
  26. 'destination' => $test_conf->{'CONTACTIRC'},
  27. 'subject' => 'My Super cool test notification',
  28. 'content' => "This is a test of Cpanel::iContact::Provider::IRC. Please Ignore",
  29. );
  30. {
  31. no warnings qw{redefine once};
  32. local *Cpanel::iContact::Provider::IRC::new = sub {
  33. return bless {
  34. 'contact' => $test_conf,
  35. }, $_[0];
  36. };
  37. my $spammer = Cpanel::iContact::Provider::IRC->new();
  38. is( exception { $spammer->_send(%args) }, undef, "Didn't fail to send notification using full functional test" );
  39. }
  40. }
  41. # TODO error paths