File Coverage

blib/lib/KiokuDB/Test/Fixture/Scan.pm
Criterion Covered Total %
statement 50 50 100.0
branch n/a
condition n/a
subroutine 11 11 100.0
pod 0 2 0.0
total 61 63 96.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Test::Fixture::Scan;
4 2     2   1567 use Moose;
  2         4  
  2         13  
5              
6 2     2   9899 use Test::More;
  2         5  
  2         18  
7 2     2   1663 use Test::Moose;
  2         2179  
  2         8  
8              
9 2     2   755 use KiokuDB::Test::Person;
  2         4  
  2         42  
10              
11 2     2   8 use namespace::clean -except => 'meta';
  2         4  
  2         24  
12              
13             with qw(KiokuDB::Test::Fixture) => { excludes => 'required_backend_roles' };
14              
15 2     2   871 use constant required_backend_roles => qw(Clear Scan);
  2         4  
  2         1095  
16              
17             sub create {
18 66     66 0 145 my $self = shift;
19              
20 66         2319 ( map { KiokuDB::Test::Person->new(%$_) }
  198         5433  
21             { name => "foo", age => 3 },
22             { name => "bar", age => 3 },
23             { name => "gorch", age => 5, friends => [ KiokuDB::Test::Person->new( name => "quxx", age => 6 ) ] },
24             );
25             }
26              
27             before populate => sub {
28             my $self = shift;
29             $self->backend->clear;
30             };
31              
32             sub verify {
33 33     33 0 93 my $self = shift;
34              
35             $self->txn_lives(sub {
36 33     33   209 my $root = $self->root_set;
37              
38 33         233 does_ok( $root, "Data::Stream::Bulk" );
39              
40 33         16936 my @objs = $root->all;
41              
42 33         1536 my @ids = $self->objects_to_ids(@objs);
43              
44 99         2594 is_deeply(
45 33         102 [ sort map { $_->name } @objs ],
46             [ sort qw(foo bar gorch) ],
47             "root set",
48             );
49              
50 33         22807 is_deeply(
51             [ sort $self->backend->root_entry_ids->all ],
52             [ sort @ids ],
53             "root set IDs",
54             );
55 33         331 });
56              
57             $self->txn_lives(sub {
58 33     33   140 my $child_entries = $self->backend->child_entries;
59              
60 33         252 does_ok( $child_entries, "Data::Stream::Bulk" );
61 33         16059 my $children = $child_entries->filter(sub {[ $self->directory->linker->register_and_expand_entries(@$_) ]});
  33         3603  
62              
63 33         236 my @objs = $children->all;
64              
65 33         3386 my @ids = $self->objects_to_ids(@objs);
66              
67 33         1099 is_deeply(
68 33         94 [ sort map { $_->name } @objs ],
69             [ sort qw(quxx) ],
70             "nonroot entries",
71             );
72              
73 33         18897 is_deeply(
74             [ sort $self->backend->child_entry_ids->all ],
75             [ sort @ids ],
76             "nonroot IDs",
77             );
78 33         12348 });
79              
80             $self->txn_lives(sub {
81 33     33   145 my $all_entries = $self->backend->all_entries;
82              
83 33         1915 does_ok( $all_entries, "Data::Stream::Bulk" );
84              
85 33         15223 my $all = $all_entries->filter(sub {[ $self->directory->linker->register_and_expand_entries(@$_) ]});
  33         3364  
86              
87 33         274 my @objs = $all->all;
88              
89 33         3528 my @ids = $self->objects_to_ids(@objs);
90              
91 132         3221 is_deeply(
92 33         98 [ sort map { $_->name } @objs ],
93             [ sort qw(foo bar gorch quxx) ],
94             "all entries",
95             );
96              
97 33         20687 is_deeply(
98             [ sort $self->backend->all_entry_ids->all ],
99             [ sort @ids ],
100             "all IDs",
101             );
102 33         12048 });
103             }
104              
105             __PACKAGE__->meta->make_immutable;
106              
107             __PACKAGE__
108              
109             __END__
110