AWS-CLIWrapper

 view release on metacpan or  search on metacpan

t/05_catch_error_options.t  view on Meta::CPAN

use 5.008001;
use strict;
use warnings;
no warnings 'uninitialized';

use Test::More;
use AWS::CLIWrapper;

my %default_args = (
  awscli_path => 't/bin/mock-aws',
  nofork => 1,
);

my $tests = eval join "\n", <DATA> or die "$@";

for my $test_name (keys %$tests) {
  next if @ARGV and not grep { $_ eq $test_name } @ARGV;

  my $test = $tests->{$test_name};
  my ($args, $env, $method, $want) = @$test{qw(args env method want)};

  $env = {} unless $env;

  local @ENV{keys %$env} = values %$env;

  my $aws = AWS::CLIWrapper->new(%default_args, %{$args || {}});
  my $have = $aws->$method;

  if ('ARRAY' eq ref $want) {
    cmp_ok $have, $_->[0], $_->[1], "$test_name " . (join ' ', @$_) for @$want;
  }
  else {
    is $have, $want, $test_name;
  }
}


done_testing;

__DATA__
# line 41
{
  'mock-aws version' => {
    method => 'awscli_version',
    want => '2.42.4242',
  },
  'default-catch_error_pattern' => {
    method => 'catch_error_pattern',
    want => undef,
  },
  'default-catch_error_retries' => {
    method => 'catch_error_retries',
    want => 3,
  },
  'default-catch_error_min_delay' => {
    method => 'catch_error_min_delay',
    want => 3,
  },
  'default-catch_error_max_delay' => {
    method => 'catch_error_max_delay',
    want => 10,
  },
  'default-catch_error_delay' => {
    method => 'catch_error_delay',
    want => [['>=', 3], ['<=', 10]],
  },



( run in 0.954 second using v1.01-cache-2.11-cpan-39bf76dae61 )