Amazon-S3
view release on metacpan or search on metacpan
t/04-list-buckets.t view on Meta::CPAN
#!/usr/bin/perl -w
## no critic
use warnings;
use strict;
use lib qw(. .. lib);
use English qw(-no_match_vars);
use S3TestUtils qw(:constants :subs);
use Test::More;
use Data::Dumper;
my $host = set_s3_host();
if ( !$ENV{'AMAZON_S3_EXPENSIVE_TESTS'} ) {
plan skip_all => 'Testing this module for real costs money.';
}
else {
plan tests => 11;
}
########################################################################
# BEGIN TESTS
########################################################################
use_ok('Amazon::S3');
use_ok('Amazon::S3::Bucket');
my $s3 = get_s3_service($host);
my $bucket_name = make_bucket_name();
my $bucket_obj = create_bucket( $s3, $bucket_name );
ok( ref $bucket_obj, 'created bucket - ' . $bucket_name );
if ( $EVAL_ERROR || !$bucket_obj ) {
BAIL_OUT( $s3->err . ": " . $s3->errstr );
}
my $bad_bucket = $s3->bucket( { bucket => 'does-not-exists' } );
my $response = $bad_bucket->list( { bucket => $bad_bucket } );
ok( !defined $response, 'undef returned on non-existent bucket' );
like( $bad_bucket->errstr, qr/does\snot\sexist/xsm, 'errstr populated' )
or diag(
Dumper(
[ response => $response,
errstr => $bad_bucket->errstr,
err => $bad_bucket->err,
]
)
);
my $max_keys = 25;
########################################################################
subtest 'list (check response elements)' => sub {
########################################################################
my $response = $bucket_obj->list
or BAIL_OUT( $s3->err . ": " . $s3->errstr );
( run in 1.447 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )