Shared/Examples/Net/Amazon/S3/Fixture.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 3 totaltotal 89.2% 25 / 28 SCAR 6.9
CC
2
Cov
100%
error_fixture
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Net/Amazon/S3/Operation/Buckets/List/Response.pm ↑ Summary Net/Amazon/S3/Error/Handler/X.pm »
1 package Shared::Examples::Net::Amazon::S3::Fixture;
2 # ABSTRACT: used for testing to provide test fixtures
3 40 $Shared::Examples::Net::Amazon::S3::Fixture::VERSION = '0.991';
4 40 ▶use parent qw[ Exporter::Tiny ];
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 40 ▶use HTTP::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 our @EXPORT_OK = (
9 qw[ error_fixture ],
10 qw[ response_fixture ],
11 qw[ fixture ],
12 );
13  
14 sub response_fixture {
15 86 ▶ my (%params) = @_;
Subroutine response_fixture: called CC=1 SCAR=0.0
Pod undocumented
16  
17 return +{
18 content_type => 'application/xml',
19 content_length => length $params{with_response_data},
20 86 response_code => HTTP::Status::HTTP_OK,
21  
22 %params,
23 };
24 }
25  
26 sub fixture {
27 33 ▶ my (%params) = @_;
Subroutine fixture: called CC=1 SCAR=0.0
Pod undocumented
28  
29 return +{
30 content_type => 'application/xml',
31 content_length => length $params{with_response_data},
32 33 response_code => HTTP::Status::HTTP_OK,
33  
34 %params,
35 };
36 }
37  
38 sub error_fixture {
39 86 ▶ my ($error_code, $http_status, $error_message) = @_;
Subroutine error_fixture: called CC=2 SCAR=6.9
Pod undocumented
40  
41 86 ▶ unless (defined $error_message) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $error_message) 85 1 86
42 85 $error_message = $error_code;
43 85 $error_message =~ s/ (?<=[[:lower:]]) ([[:upper:]])/ \L$1\E/gx;
44 }
45  
46 86 return response_fixture (
47 response_code => $http_status,
48 content => <<"XML",
49 <?xml version="1.0" encoding="UTF-8"?>
50 <Error>
51 <Code>$error_code</Code>
52 <Message>$error_message error message</Message>
53 <Resource>/some-resource</Resource>
54 <RequestId>4442587FB7D0A2F9</RequestId>
55 </Error>
56 XML
57 );
58 }
59  
60 40 1;
61  
62 __END__
63  
64 =pod
65  
66 =encoding UTF-8
67  
68 =head1 NAME
69  
70 Shared::Examples::Net::Amazon::S3::Fixture - used for testing to provide test fixtures
71  
72 =head1 VERSION
73  
74 version 0.991
75  
76 =head1 AUTHOR
77  
78 Branislav Zahradník <barney@cpan.org>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
« Net/Amazon/S3/Operation/Buckets/List/Response.pm ↑ Summary Net/Amazon/S3/Error/Handler/X.pm »