AnyEvent-Net-Amazon-S3
view release on metacpan or search on metacpan
t/02client.t view on Meta::CPAN
#!perl
use warnings;
use strict;
use lib 'lib';
use Digest::MD5::File qw(file_md5_hex);
use LWP::Simple;
use File::stat;
use Test::More;
use Test::Exception;
use File::Temp qw/ :seekable /;
unless ( $ENV{'AMAZON_S3_EXPENSIVE_TESTS'} ) {
plan skip_all => 'Testing this module for real costs money.';
} else {
plan tests => 54;
}
use_ok('AnyEvent::Net::Amazon::S3');
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'};
my $aws_secret_access_key = $ENV{'AWS_ACCESS_KEY_SECRET'};
my $s3 = AnyEvent::Net::Amazon::S3->new(
aws_access_key_id => $aws_access_key_id,
aws_secret_access_key => $aws_secret_access_key,
retry => 1,
);
my $readme_size = stat('README')->size;
my $readme_md5hex = file_md5_hex('README');
my $client = AnyEvent::Net::Amazon::S3::Client->new( s3 => $s3 );
my @buckets = $client->buckets;
TODO: {
local $TODO = "These tests only work if you're pedro";
my $first_bucket = $buckets[0];
like( $first_bucket->owner_id, qr/^c7483d612ac7f0c0/, 'have owner id' );
is( $first_bucket->owner_display_name, 'pedro_figueiredo', 'have display name' );
is( scalar @buckets, 6, 'have a bunch of buckets' );
}
my $bucket_name = 'net-amazon-s3-test-' . lc($aws_access_key_id) . '-'. time;
my $bucket = $client->create_bucket(
name => $bucket_name,
acl_short => 'public-read',
location_constraint => 'US',
);
is( $bucket->name, $bucket_name, 'newly created bucket has correct name' );
like(
$bucket->acl,
qr{<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>[a-z0-9]{64}</ID><DisplayName>.+?</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Canonical...
'newly created bucket is public-readable'
);
is( $bucket->location_constraint, 'US', 'newly created bucket is in the US' );
my $stream = $bucket->list;
until ( $stream->is_done ) {
foreach my $object ( $stream->items ) {
( run in 0.552 second using v1.01-cache-2.11-cpan-39bf76dae61 )