SDK/Storage/Tables/Transaction.pm

filter: Statementstmt 93.7% 45 / 48 Branchbran 83.3% 15 / 18 Conditioncond 66.6% 10 / 15 MC/DCmcdc 33.3% 3 / 9 Subroutinesub 81.2% 13 / 16 Podpod 0.0% 0 / 9 totaltotal 74.7% 86 / 115 CC 15 SCAR 21.5
CC
15
Cov
86%
_add
15.9
insert_or_replace
2.0
insert_or_merge
2.0
CRAP 8.6
« SDK/Storage/Tables/TransactionResultItem.pm ↑ Summary SDK/Storage/Queues.pm »
1 6 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 6 ▶use Azure::SDK::Storage::Tables::TransactionOperation;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 6 class Azure::SDK::Storage::Tables::Transaction {
8 6 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10
11 6 field $operations = [];
12 6 field $partition_key = undef;
13 6 field $seen = {};
14
15 112 ▶ method insert ($entity) {
Subroutine insert: called CC=1 SCAR=0.0
Pod undocumented
16 112 return $self->_add('insert', $entity);
17 }
18
19 2 ▶ method replace ($entity, %options) {
Subroutine replace: called CC=1 SCAR=0.0
Pod undocumented
20 2 return $self->_add('replace', $entity, %options);
21 }
22
23 1 ▶ method merge ($entity, %options) {
Subroutine merge: called CC=1 SCAR=0.0
Pod undocumented
24 1 return $self->_add('merge', $entity, %options);
25 }
26
27 2 ▶ method delete ($entity, %options) {
Subroutine delete: called CC=1 SCAR=0.0
Pod undocumented
28 2 return $self->_add('delete', $entity, %options);
29 }
30
31 0 ▶ method insert_or_replace ($entity) {
Subroutine insert_or_replace: not called CC=1 SCAR=6.9
Pod undocumented
32 0 return $self->_add('insert_or_replace', $entity);
33 }
34
35 0 ▶ method insert_or_merge ($entity) {
Subroutine insert_or_merge: not called CC=1 SCAR=6.9
Pod undocumented
36 0 return $self->_add('insert_or_merge', $entity);
37 }
38
39 3 ▶ method operations () {
Subroutine operations: called CC=1 SCAR=0.0
Pod undocumented
40 3 return [$operations->@*];
41 }
42
43 123 ▶ method count () {
Subroutine count: called CC=1 SCAR=0.0
Pod undocumented
44 123 return scalar $operations->@*;
45 }
46
47 0 ▶ method partition_key () {
Subroutine partition_key: not called CC=1 SCAR=6.9
Pod undocumented
48 0 return $partition_key;
49 }
50
51 117 ▶ method _add ($action, $entity, %options) {
Subroutine _add: called CC=15 SCAR=27.7
52 croak 'Unknown Table transaction option(s): ' . join(', ', sort keys %options)
53 117 ▶ if grep { $_ ne 'if_match' } keys %options;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ ne "if_match";} keys %options 0 117 117
54 croak "Table transaction $action does not accept if_match"
55 if exists $options{if_match}
56 117 ▶ && $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"if_match"} and $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u 0 117 117
Condition66%2/3
exists $options{"if_match"} and $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
!ll&&!rl&&r
11610
MC/DC0%0/2
exists $options{"if_match"} and $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
exists $options{"if_match"} $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
Truth table66%2/3
A and B
A= exists $options{"if_match"}B= $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
ABresult
0X0
100
111
57 117 ▶ croak 'Table transaction supports at most 100 operations'
Branch: 1 branch
BranchTrueFalseTotal
if $self->count >= 100 1 116 117
58 if $self->count >= 100;
59 116 ▶ croak 'Table transaction operation requires an Entity'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity") 0 116 116
Condition33%1/3
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
!ll&&!rl&&r
00116
MC/DC0%0/2
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
builtin::blessed($entity) $entity->isa("Azure::SDK::Storage::Tables::Entity")
Truth table33%1/3
A and B
A= builtin::blessed($entity)B= $entity->isa("Azure::SDK::Storage::Tables::Entity")
ABresult
0X0
100
111
60 unless blessed($entity)
61 && $entity->isa('Azure::SDK::Storage::Tables::Entity');
62
63 116 ▶ if (defined $partition_key) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $partition_key) { } 108 8 116
64 108 ▶ croak 'Table transaction operations must use the same partition'
Branch: 1 branch
BranchTrueFalseTotal
unless $entity->partition_key eq $partition_key 1 107 108
65 unless $entity->partition_key eq $partition_key;
66 }
67 else {
68 8 $partition_key = $entity->partition_key;
69 }
70
71 115 my $identity = $entity->partition_key . "\0" . $entity->row_key;
72 croak 'A Table transaction entity may appear only once'
73 115 ▶ if $seen->{$identity};
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{$identity} 1 114 115
74
75 114 my $if_match;
76 114 ▶ if ($action =~ /\A(?:replace|merge|delete)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action =~ /\A(?:replace|merge|delete)\z/u) 4 110 114
77 4 ▶ $if_match = $options{if_match} // $entity->etag;
Condition100%3/3
$options{"if_match"} // $entity->etag
l!l&&r!l&&!r
112
MC/DC100%2/2
$options{"if_match"} // $entity->etag
$options{"if_match"} $entity->etag
Truth table100%3/3
A // B
A= $options{"if_match"}B= $entity->etag
ABresult
1X1
011
000
78 4 ▶ croak "Table transaction $action if_match is required; use \"*\" for an unconditional mutation"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $if_match and not ref $if_match and length $if_match 2 2 4
Condition66%4/6
defined $if_match and not ref $if_match and length $if_match
!ll&&!rl&&r
202
defined $if_match and not ref $if_match
!ll&&!rl&&r
202
MC/DC33%1/3
defined $if_match and not ref $if_match and length $if_match
defined $if_match not ref $if_match length $if_match
Truth table50%2/4
A and not(B) and C
A= defined $if_matchB= not ref $if_matchC= length $if_match
ABCresult
0XX0
10X0
1100
1111
79 unless defined $if_match && !ref($if_match) && length($if_match);
80 }
81
82 112 push $operations->@*, Azure::SDK::Storage::Tables::TransactionOperation->new(
83 action => $action,
84 entity => $entity,
85 if_match => $if_match,
86 );
87 112 $seen->{$identity} = 1;
88 112 return $self;
89 }
90 }
91
92 6 1;
93
94 __END__
« SDK/Storage/Tables/TransactionResultItem.pm ↑ Summary SDK/Storage/Queues.pm »