Amazon-S3

 view release on metacpan or  search on metacpan

t/01-api.t  view on Meta::CPAN

#!/usr/bin/env perl -w

use warnings;
use strict;

use lib qw( . .. lib);

use Data::Dumper;
use Digest::MD5::File qw(file_md5_hex);
use English qw(-no_match_vars);
use File::Temp qw( tempfile );
use List::Util qw(any);
use Test::More;

use S3TestUtils qw(:constants :subs);

our @REGIONS = (undef);

if ( $ENV{AMAZON_S3_REGIONS} ) {
  push @REGIONS, split /\s*,\s*/xsm, $ENV{AMAZON_S3_REGIONS};
}

my $host = set_s3_host();

my $bucket_name = make_bucket_name();

if ( !$ENV{AMAZON_S3_EXPENSIVE_TESTS} ) {
  plan skip_all => 'Testing this module for real costs money.';
}
else {
  plan tests => 85 * scalar(@REGIONS) + 2;
}

########################################################################
# BEGIN TESTS
########################################################################

use_ok('Amazon::S3');
use_ok('Amazon::S3::Bucket');

my $s3 = get_s3_service($host);

if ( !$s3 || $EVAL_ERROR ) {
  BAIL_OUT( 'could not initialize s3 object: ' . $EVAL_ERROR );
}

# bail if test bucket already exists
our ( $OWNER_ID, $OWNER_DISPLAYNAME ) = check_test_bucket($s3);

for my $location (@REGIONS) {
  # this test formerly used the same bucket name for both regions,
  # however when you delete a bucket it may take up to an hour for
  # that bucket name to be available again when using AWS as the host.
  # To test the bucket constraint policy below then we need to use a
  # different bucket name. The old comment here was...
  #
  #   > create a bucket
  #   > make sure it's a valid hostname for EU testing
  #   > we use the same bucket name for both in order to force one or the
  #   > other to have stale DNS

  $s3->region($location);
  $host = $s3->host;

  my $bucket_name_raw;
  my $bucket_name;



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