Cpanel-iContact-Provider-IRC.t 1.5 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' => 3;
  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. # TODO finish unit test.
  16. no warnings qw{redefine once};
  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->{'CONTACTIRC'} ],
  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::IRC->new();
  37. is( exception { $spammer->_send(%args) }, undef, "Didn't fail to send notification using full functional test" );
  38. }
  39. }
  40. # TODO error paths