KiokuDB/Test/Fixture/Overwrite.pm

filter: Statementstmt 96.3% 79 / 82 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 95.4% 21 / 22 Podpod 0.0% 0 / 6 totaltotal 89.2% 100 / 112 CC 2 SCAR 3.6
CC
2
Cov
94%
p
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« KiokuDB/Test/Fixture/TXN/Nested.pm ↑ Summary KiokuDB/Backend/Serialize/Memory.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Test::Fixture::Overwrite;
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Test::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use KiokuDB::Test::Person;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use KiokuDB::Test::Employee;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use KiokuDB::Test::Company;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 {
16 2 package KiokuDB::Test::BLOB;
17 2 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 with qw(KiokuDB::Role::ID::Content);
20  
21 sub kiokudb_object_id {
22 83 ▶ my $self = shift;
Subroutine kiokudb_object_id: called CC=1 SCAR=0.0
Pod undocumented
23 83 $self->data;
24 }
25  
26 2 has data => (
27 isa => "Str",
28 is => "ro",
29 required => 1,
30 );
31 }
32  
33 sub p {
34 0 ▶ my @args = @_;
Subroutine p: not called CC=2 SCAR=17.9
Pod undocumented
35 0 ▶ unshift @args, "name" if @args % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 0 0 0
36 0 KiokuDB::Test::Person->new(@args);
37 }
38  
39 2 with qw(KiokuDB::Test::Fixture) => { excludes => [qw/populate sort/] };
40  
41 10 ▶sub sort { -100 }
Subroutine sort: called CC=1 SCAR=0.0
Pod undocumented
42  
43 sub create {
44 return (
45 33 ▶ KiokuDB::Test::Person->new(
Subroutine create: called CC=1 SCAR=0.0
Pod undocumented
46 name => "blah",
47 ),
48 KiokuDB::Test::BLOB->new(
49 data => "lalala",
50 ),
51 );
52 }
53  
54 sub populate {
55 33 ▶ my $self = shift;
Subroutine populate: called CC=1 SCAR=0.0
Pod undocumented
56  
57 {
58 33 my $s = $self->new_scope;
59  
60 33 my ( $p, $b ) = $self->create;
61  
62 33 isa_ok( $p, "KiokuDB::Test::Person" );
63 33 isa_ok( $b, "KiokuDB::Test::BLOB" );
64  
65 33 $self->store_ok( person => $p, $b );
66  
67 33 $self->live_objects_are($p, $b);
68 }
69  
70 33 $self->no_live_objects;
71 }
72  
73 sub verify {
74 33 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
75  
76 {
77 33 my $s = $self->new_scope;
78  
79 33 my $p = $self->lookup_ok("person");
80  
81 33 isa_ok( $p, "KiokuDB::Test::Person" );
82  
83 33 is( $p->name, "blah", "name attr" );
84  
85 25 $p->name("new name");
86  
87 lives_ok {
88 25 ▶ $self->directory->store($p);
Subroutine __ANON__: called CC=1 SCAR=0.0
89 25 } "update";
90 }
91  
92 25 $self->no_live_objects;
93  
94 {
95 25 my $s = $self->new_scope;
96  
97 25 my $b = $self->lookup_ok("lalala");
98  
99 25 isa_ok( $b, "KiokuDB::Test::BLOB" );
100  
101 25 is( $b->data, "lalala", "data attr" );
102  
103 25 my $entry = $self->directory->live_objects->object_to_entry($b);
104  
105 lives_ok {
106 25 ▶ $self->directory->store($b);
Subroutine __ANON__: called CC=1 SCAR=0.0
107 25 } "update (noop)";
108  
109 25 my $new_entry = $self->directory->live_objects->object_to_entry($b);
110  
111 25 is( refaddr($new_entry), refaddr($entry), "entry refaddr unchanged" );
112 }
113  
114 25 $self->no_live_objects;
115  
116 dies_ok {
117 25 ▶ my $s = $self->new_scope;
Subroutine __ANON__: called CC=1 SCAR=0.0
118 $self->txn_do(sub {
119 25 ▶ $self->directory->store( person => KiokuDB::Test::Person->new( name => "duplicate" ) );
Subroutine __ANON__: called CC=1 SCAR=0.0
120 25 });
121 25 } "can't insert duplicate";
122  
123 25 $self->no_live_objects;
124  
125 lives_ok {
126 25 ▶ my $s = $self->new_scope;
Subroutine __ANON__: called CC=1 SCAR=0.0
127 $self->txn_do(sub {
128 25 ▶ my $id = $self->directory->store( KiokuDB::Test::BLOB->new( data => "lalala" ) );
Subroutine __ANON__: called CC=1 SCAR=0.0
129 25 });
130 25 } "not an error to insert a duplicate of a content addressed object";
131  
132 25 $self->no_live_objects;
133  
134 lives_ok {
135 25 ▶ my $s = $self->new_scope;
Subroutine __ANON__: called CC=1 SCAR=0.0
136  
137 25 my $b = $self->lookup_ok("lalala");
138  
139 $self->txn_do(sub {
140 25 ▶ my $id = $self->directory->store( KiokuDB::Test::BLOB->new( data => "lalala" ) );
Subroutine __ANON__: called CC=1 SCAR=0.0
141 25 });
142 25 } "not an error to insert a duplicate of a live content addressed object";
143  
144 25 $self->no_live_objects;
145 }
146  
147 2 __PACKAGE__
148  
149 __END__
150  
« KiokuDB/Test/Fixture/TXN/Nested.pm ↑ Summary KiokuDB/Backend/Serialize/Memory.pm »