File: api-build-bucket.t

package info (click to toggle)
libnet-amazon-s3-perl 0.991-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,620 kB
  • sloc: perl: 9,906; makefile: 20
file content (71 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!perl

use strict;
use warnings;

use FindBin;
use lib $FindBin::Bin;

BEGIN { require "test-helper-common.pl" }

use Scalar::Util;

plan tests => 6;

sub build_bucket;
sub test_method_bucket;

SKIP:
{
	require_ok ('Net::Amazon::S3') or skip "Cannot load module", 2;

	test_method_bucket
		"bucket (STRING) should return respective bucket object",
		build_bucket ('foo'),
		obj_isa ('Net::Amazon::S3::Bucket'),
		methods (bucket => 'foo'),
		;

	test_method_bucket
		"bucket (bucket => STRING) should return respective bucket object",
		build_bucket (bucket => 'foo'),
		obj_isa ('Net::Amazon::S3::Bucket'),
		methods (bucket => 'foo'),
		;

	test_method_bucket
		"bucket (STRING, region => STRING) should return respective bucket object",
		build_bucket ('foo', region => 'bar'),
		obj_isa ('Net::Amazon::S3::Bucket'),
		methods (bucket => 'foo', region =>'bar'),
		;

	my $bar = build_bucket ('bar');
	test_method_bucket
		"bucket (Instance) should return its argument",
		scalar build_bucket ($bar),
		obj_isa ('Net::Amazon::S3::Bucket'),
		methods (bucket => 'bar'),
		code (sub {
			return 1 if Scalar::Util::refaddr ($_[0]) == Scalar::Util::refaddr ($bar);
			return 0, "Object is has different address"
		}),
		;
}

had_no_warnings;

done_testing;

sub build_bucket {
	my $s3 = bless {}, 'Net::Amazon::S3';

	$s3->bucket (@_);
}

sub test_method_bucket {
	my ($title, $bucket, @plan) = @_;

	it $title, got => $bucket, expect => all (@plan);
}