KiokuDB/Test/Fixture/Refresh.pm

filter: Statementstmt 92.8% 39 / 42 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 5 totaltotal 81.6% 49 / 60 CC 2 SCAR 6.1
CC
2
Cov
89%
p
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« KiokuDB/Error/MissingObjects.pm ↑ Summary KiokuDB/LiveObjects/TXNScope.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Test::Fixture::Refresh;
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 KiokuDB::Test::Person;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub p {
12 0 ▶ my @args = @_;
Subroutine p: not called CC=2 SCAR=17.9
Pod undocumented
13 0 ▶ unshift @args, "name" if @args % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 0 0 0
14 0 KiokuDB::Test::Person->new(@args);
15 }
16  
17 2 with qw(KiokuDB::Test::Fixture) => { excludes => [qw/populate sort/] };
18  
19 8 ▶sub sort { -100 }
Subroutine sort: called CC=1 SCAR=0.0
Pod undocumented
20  
21 sub create {
22 return (
23 33 ▶ KiokuDB::Test::Person->new(
Subroutine create: called CC=1 SCAR=0.0
Pod undocumented
24 name => "julie",
25 age => 10,
26 ),
27 );
28 }
29  
30 sub populate {
31 33 ▶ my $self = shift;
Subroutine populate: called CC=1 SCAR=0.0
Pod undocumented
32  
33 {
34 33 my $s = $self->new_scope;
35  
36 33 my $obj = $self->create;
37  
38 33 isa_ok( $obj, "KiokuDB::Test::Person" );
39  
40 33 $self->store_ok( refresh_obj => $obj );
41  
42 33 $self->live_objects_are($obj);
43 }
44  
45 33 $self->no_live_objects;
46 }
47  
48 sub verify {
49 33 ▶ my $self = shift;
Subroutine verify: called CC=1 SCAR=0.0
Pod undocumented
50  
51 $self->txn_lives(sub {
52 33 ▶ my $obj = $self->lookup_ok("refresh_obj");
Subroutine __ANON__: called CC=1 SCAR=0.0
53  
54 33 isa_ok( $obj, "KiokuDB::Test::Person" );
55  
56 33 is( $obj->name, "julie", "name" );
57  
58 25 my $dir = $self->directory;
59  
60 25 isa_ok( my $entry = $dir->live_objects->object_to_entry($obj), "KiokuDB::Entry" );
61  
62 25 my $updated = $entry->clone( prev => $entry );
63 25 $updated->data->{age} = 1841;
64  
65 25 is( $obj->age, 10, "age attr" );
66  
67 25 $dir->backend->insert( $updated );
68  
69 25 is( $obj->age, 10, "age attr not updated even though it was written" );
70  
71 25 ▶ lives_ok { $dir->refresh($obj) } "no error in refresh";
Subroutine __ANON__: called CC=1 SCAR=0.0
72  
73 25 is( $obj->age, 1841, "age updated" );
74 33 });
75 }
76 2 __PACKAGE__
77  
« KiokuDB/Error/MissingObjects.pm ↑ Summary KiokuDB/LiveObjects/TXNScope.pm »