File Coverage

blib/lib/KiokuDB/Test/Fixture/SimpleSearch.pm
Criterion Covered Total %
statement 40 40 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 2 0.0
total 48 50 96.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Test::Fixture::SimpleSearch;
4 2     2   1462 use Moose;
  2         3  
  2         13  
5              
6 2     2   9768 use Test::More;
  2         4  
  2         17  
7 2     2   507 use Test::Moose;
  2         3  
  2         21  
8              
9 2     2   783 use KiokuDB::Test::Person;
  2         4  
  2         48  
10              
11 2     2   7 use namespace::clean -except => 'meta';
  2         2  
  2         17  
12              
13             with qw(KiokuDB::Test::Fixture) => { excludes => 'required_backend_roles' };
14              
15 2     2   823 use constant required_backend_roles => qw(Clear Query::Simple);
  2         3  
  2         745  
16              
17             sub create {
18 33     33 0 71 my $self = shift;
19              
20 33         1180 ( map { KiokuDB::Test::Person->new(%$_) }
  99         2773  
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 87 my $self = shift;
34              
35             {
36 33         55 my $s = $self->new_scope;
  33         151  
37              
38 33         259 my $res = $self->search({ name => "foo" });
39              
40 33         243 does_ok( $res, "Data::Stream::Bulk" );
41              
42 33         19092 my @objs = $res->all;
43              
44 33         1505 is( @objs, 1, "one object" );
45              
46 33         14242 is( $objs[0]->name, "foo", "name attr" );
47             }
48              
49 33         222 $self->no_live_objects;
50              
51             {
52 33         59 my $s = $self->new_scope;
  33         168  
53              
54 33         195 my $res = $self->search({ age => 3 });
55              
56 33         191 does_ok( $res, "Data::Stream::Bulk" );
57              
58 33         14338 my @objs = $res->all;
59              
60 33         1564 is( @objs, 2, "two objects" );
61              
62 33         13372 @objs = sort { $a->name cmp $b->name } @objs;
  33         1227  
63              
64 33         882 is( $objs[0]->name, "bar", "name attr" );
65 33         11682 is( $objs[1]->name, "foo", "name attr" );
66             }
67             }
68              
69             __PACKAGE__->meta->make_immutable;
70              
71             __PACKAGE__
72              
73             __END__
74