Net-OpenSSH-More.t 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. use strict;
  2. use warnings;
  3. use Test2::V0;
  4. use Test2::Tools::Explain;
  5. use Test2::Plugin::NoWarnings;
  6. use Test::MockModule qw{strict};
  7. use Carp::Always;
  8. use FindBin;
  9. use lib "$FindBin::Bin/../lib";
  10. use Net::OpenSSH::More;
  11. subtest "Live tests versus localhost" => sub {
  12. plan 'skip_all' => 'AUTHOR_TESTS not set in shell environment, skipping...' if !$ENV{'AUTHOR_TESTS'};
  13. my $obj = Net::OpenSSH::More->new( '127.0.0.1' );
  14. is( ref $obj, 'Net::OpenSSH::More', "Got right ref type for object upon instantiation (using IP)" );
  15. $obj = Net::OpenSSH::More->new( 'localhost' );
  16. is( ref $obj, 'Net::OpenSSH::More', "Got right ref type for object upon instantiation (using localhost)" );
  17. };
  18. # Mock based testing
  19. subtest "Common tests using mocks" => sub {
  20. my $parent_mock = Test::MockModule->new('Net::OpenSSH');
  21. $parent_mock->redefine(
  22. 'new' => sub { bless {}, $_[0] },
  23. 'check_master' => 1,
  24. 'DESTROY' => undef,
  25. );
  26. local $Net::OpenSSH::More::disable_destructor = 1;
  27. my $obj = Net::OpenSSH::More->new( '127.0.0.1', retry_max => 1 );
  28. is( ref $obj, 'Net::OpenSSH::More', "Got right ref type for object upon instantiation" );
  29. };
  30. done_testing();