| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package KiokuDB::Test::Fixture::SimpleSearch; | ||
| 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::Moose; |
|
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 | 2 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 2 | with qw(KiokuDB::Test::Fixture) => { excludes => 'required_backend_roles' }; | |
| 14 | |||
| 15 | 2 | ▶ | use constant required_backend_roles => qw(Clear Query::Simple); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | sub create { | ||
| 18 | 33 | ▶ | my $self = shift; |
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 19 | |||
| 20 | 33 | ( map { KiokuDB::Test::Person->new(%$_) } | |
| 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 | 33 | ▶ | my $self = shift; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 29 | 33 | $self->backend->clear; | |
| 30 | 2 | }; | |
| 31 | |||
| 32 | sub verify { | ||
| 33 | 33 | ▶ | my $self = shift; |
|
Subroutine
verify: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 34 | |||
| 35 | { | ||
| 36 | 33 | my $s = $self->new_scope; | |
| 37 | |||
| 38 | 33 | my $res = $self->search({ name => "foo" }); | |
| 39 | |||
| 40 | 25 | does_ok( $res, "Data::Stream::Bulk" ); | |
| 41 | |||
| 42 | 25 | my @objs = $res->all; | |
| 43 | |||
| 44 | 25 | is( @objs, 1, "one object" ); | |
| 45 | |||
| 46 | 25 | is( $objs[0]->name, "foo", "name attr" ); | |
| 47 | } | ||
| 48 | |||
| 49 | 25 | $self->no_live_objects; | |
| 50 | |||
| 51 | { | ||
| 52 | 25 | my $s = $self->new_scope; | |
| 53 | |||
| 54 | 25 | my $res = $self->search({ age => 3 }); | |
| 55 | |||
| 56 | 25 | does_ok( $res, "Data::Stream::Bulk" ); | |
| 57 | |||
| 58 | 25 | my @objs = $res->all; | |
| 59 | |||
| 60 | 25 | is( @objs, 2, "two objects" ); | |
| 61 | |||
| 62 | 25 | @objs = sort { $a->name cmp $b->name } @objs; | |
| 63 | |||
| 64 | 25 | is( $objs[0]->name, "bar", "name attr" ); | |
| 65 | 25 | is( $objs[1]->name, "foo", "name attr" ); | |
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | 2 | __PACKAGE__->meta->make_immutable; | |
| 70 | |||
| 71 | 2 | __PACKAGE__ | |
| 72 | |||
| 73 | __END__ | ||
| 74 | |||