-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.t
33 lines (26 loc) · 752 Bytes
/
index.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use strict;
use warnings;
use Test::More tests => 7;
use Test::Exception;
use t::lib::Test;
my $tmp = tmp;
my $dir = storage;
ok $dir, 'created directory';
{ my $foo = Test->new( id => 1, foo => 'Hello' );
$dir->store($foo);
ok $tmp->exists('1.json'), 'created 1.json ok';
ok $tmp->exists('.index'), 'created index ok';
my $foo2 = [$dir->search( { foo => 'Hello' } )]->[0];
is $foo2->{id}, 1;
}
$tmp->mkdir('foo');
my $dir2 = MooseX::Storage::Directory->new(
directory => $tmp->exists('foo'),
class => Test->meta,
);
ok $dir2, 'created dir2';
my $nothing;
lives_ok {
$nothing = $dir->search( { nothing => 'to search on' } );
} 'searching when there are no entries lives ok';
ok !$nothing, 'no results, and no death';