KiokuDB/Test/Fixture/TXN/Nested.pm

filter: Statementstmt 34.9% 22 / 63 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 2 totaltotal 37.1% 29 / 78 CC 1 SCAR 3.8
CC
1
Cov
35%
verify
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.5
« KiokuDB/LiveObjects/Scope.pm ↑ Summary KiokuDB/Test/Fixture/Overwrite.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Test::Fixture::TXN::Nested;
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 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 extends qw(KiokuDB::Test::Fixture::TXN);
13  
14 2 ▶use constant required_backend_roles => qw(TXN TXN::Nested);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 8 ▶sub sort { 151 } # after TXN
Subroutine sort: called CC=1 SCAR=0.0
Pod undocumented
17  
18 sub verify {
19 0 ▶ my $self = shift;
Subroutine verify: not called CC=1 SCAR=6.9
Pod undocumented
20  
21 0 my $l = $self->directory->live_objects;
22  
23 {
24 0 {
25 0 my $s = $self->new_scope;
26  
27 0 my $joe = $self->lookup_ok( $self->joe );
28  
29 0 is( $joe->name, "joe", "name attr" );
30  
31 0 my $entry = $l->objects_to_entries($joe);
32  
33 0 isa_ok( $entry, "KiokuDB::Entry" );
34  
35 throws_ok {
36 $self->txn_do(sub {
37 0 ▶ $joe->name("lalalala");
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 $self->update_ok($joe);
39  
40 0 my ( $db_entry ) = $self->backend->get( $self->joe );
41 0 is( $db_entry->data->{name}, "lalalala", "entry written to DB" );
42  
43 0 my $err;
44 try {
45 $self->txn_do(sub {
46 0 ▶ $joe->name("oi");
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 $self->update_ok($joe);
48  
49 0 my ( $inner_db_entry ) = $self->backend->get( $self->joe );
50 0 is( $inner_db_entry->data->{name}, "oi", "entry written to DB" );
51  
52 0 my $updated_entry = $l->objects_to_entries($joe);
53  
54 0 isnt( $updated_entry, $entry, "entry updated" );
55 0 is( $updated_entry->prev->prev, $entry, "parent of parent of updated is orig" );
56  
57 0 die "foo";
58 0 ▶ });
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 } catch {
60 0 ▶ $err = $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 };
62  
63 0 my ( $db_entry_rolled_back ) = $self->backend->get( $self->joe );
64 0 is( $db_entry_rolled_back->data->{name}, "lalalala", "rolled back nested txn" );
65  
66 0 die $err;
67 0 ▶ });
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 } qr/foo/, "failed transaction";
69  
70 0 my $updated_entry = $l->objects_to_entries($joe);
71  
72 0 is( $updated_entry, $entry, "entry rolled back" );
73  
74 0 is( $joe->name, "oi", "name attr of object" );
75  
76 0 undef $joe;
77 }
78  
79 0 $self->no_live_objects;
80  
81 {
82 0 my $s = $self->new_scope;
83  
84 0 my $joe = $self->lookup_ok( $self->joe );
85  
86 0 is( $joe->name, "joe", "name rolled back in DB" );
87  
88 0 undef $joe;
89 }
90  
91 0 $self->no_live_objects;
92 }
93 }
94  
95 2 __PACKAGE__->meta->make_immutable;
96  
97 2 __PACKAGE__
98  
99 __END__
« KiokuDB/LiveObjects/Scope.pm ↑ Summary KiokuDB/Test/Fixture/Overwrite.pm »