File: s3-operation-object-copy.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 (167 lines) | stat: -rw-r--r-- 4,097 bytes parent folder | download | duplicates (3)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!perl

use strict;
use warnings;

use FindBin;

BEGIN { require "$FindBin::Bin/test-helper-operation.pl" }

expect_operation_object_copy (
	'API / legacy'                      => \& api_object_copy_legacy,
	'API / legacy configuration hash'   => \& api_object_copy_legacy_config,
	'API / named arguments'             => \& api_object_copy_named,
	'API / named arguments with keys'   => \& api_object_copy_named_keys,
);

expect_operation_object_edit_metadata (
	'API / edit metadata legacy'        => \& api_object_edit_metadata_legacy,
	'API / edit metadata named'         => \& api_object_edit_metadata_named,
);

had_no_warnings;

done_testing;

sub api_object_copy_legacy {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->copy_key (
			delete $args{key},
			delete $args{source},
			\ %args
		);
}

sub api_object_copy_legacy_config {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->copy_key (
			\ %args
		);
}

sub api_object_copy_named {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->copy_key (
			%args
		);
}

sub api_object_copy_named_keys {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->copy_key (
			delete $args{key},
			delete $args{source},
			%args
		);
}

sub api_object_edit_metadata_legacy {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->edit_metadata (
			delete $args{key},
			\ %args
		);
}

sub api_object_edit_metadata_named {
	my (%args) = _api_expand_header_arguments @_;

	build_default_api_bucket (%args)
		->edit_metadata (
			%args
		);
}

sub expect_operation_object_copy {
	expect_operation_plan
		implementations => +{ @_ },
		expect_operation => 'Net::Amazon::S3::Operation::Object::Add',
		plan => {
			"copy key" => {
				act_arguments => [
					bucket      => 'bucket-name',
					key         => 'some-key',
					source      => 'source-key',
					acl_short   => 'object-acl',
					encryption  => 'object-encryption',
					headers     => {
						expires     => 2_345_567_890,
						content_encoding => 'content-encoding',
						x_amz_storage_class => 'storage-class',
						x_amz_website_redirect_location => 'location-value',
					},
					metadata => {
						foo => 'foo-value',
					},
				],
				expect_arguments => {
					bucket      => 'bucket-name',
					key         => 'some-key',
					value       => '',
					acl_short   => 'object-acl',
					encryption  => 'object-encryption',
					headers     => {
						expires     => 2_345_567_890,
						content_encoding => 'content-encoding',
						x_amz_storage_class => 'storage-class',
						x_amz_website_redirect_location => 'location-value',
						x_amz_meta_foo => 'foo-value',
						'x-amz-metadata-directive' => 'REPLACE',
						'x-amz-copy-source'        => 'source-key',
					}
				},
			},
		}
}

sub expect_operation_object_edit_metadata {
	expect_operation_plan
		implementations => +{ @_ },
		expect_operation => 'Net::Amazon::S3::Operation::Object::Add',
		plan => {
			"copy key" => {
				act_arguments => [
					bucket      => 'bucket-name',
					key         => 'some-key',
					acl_short   => 'object-acl',
					encryption  => 'object-encryption',
					headers     => {
						expires     => 2_345_567_890,
						content_encoding => 'content-encoding',
						x_amz_storage_class => 'storage-class',
						x_amz_website_redirect_location => 'location-value',
					},
					metadata => {
						foo => 'foo-value',
					},
				],
				expect_arguments => {
					bucket      => 'bucket-name',
					key         => 'some-key',
					value       => '',
					acl_short   => 'object-acl',
					encryption  => 'object-encryption',
					headers     => {
						expires     => 2_345_567_890,
						content_encoding => 'content-encoding',
						x_amz_storage_class => 'storage-class',
						x_amz_website_redirect_location => 'location-value',
						x_amz_meta_foo => 'foo-value',
						'x-amz-metadata-directive' => 'REPLACE',
						'x-amz-copy-source'        => '/bucket-name/some-key',
					}
				},
			},
		}
}