1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use Test::More tests => 37; |
use Test::More tests => 40; |
4 |
use Test::Exception; |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use blib; |
use blib; |
25 |
|
|
26 |
throws_ok { new WebPAC::Store() } qr/path/, 'new without path'; |
throws_ok { new WebPAC::Store() } qr/path/, 'new without path'; |
27 |
|
|
28 |
throws_ok { new WebPAC::Store( path => '/tmp' ) } qr/database/, 'new without database'; |
ok(new WebPAC::Store( path => '/tmp' ), 'new without database'); |
29 |
|
|
30 |
ok($db = new WebPAC::Store( path => '/tmp', database => 'foobar', debug => $debug ), "new"); |
ok($db = new WebPAC::Store( path => '/tmp', database => 'foobar', debug => $debug ), "new"); |
31 |
|
|
39 |
|
|
40 |
undef $db; |
undef $db; |
41 |
|
|
42 |
ok(my $path = tempdir( CLEANUP => 1 ), "path"); |
ok(my $path = tempdir( CLEANUP => $debug ? 0 : 1 ), "path"); |
43 |
|
|
44 |
diag "Store path: $path"; |
diag "Store path: $path"; |
45 |
|
|
103 |
foo => { 42 => 1 }, |
foo => { 42 => 1 }, |
104 |
}; |
}; |
105 |
|
|
106 |
|
ok(! $db->load_lookup( input => 'non-existant', key => 'foo' ), 'invalid load_lookup'); |
107 |
|
|
108 |
ok($db->save_lookup( input => 'foo', key => 'bar', data => $l ), "save_lookup"); |
ok($db->save_lookup( input => 'foo', key => 'bar', data => $l ), "save_lookup"); |
109 |
|
|
110 |
ok(-e $db->path . '/lookup/webpac-test/foo/bar', "exists"); |
ok(-e $db->path . '/lookup/webpac-test/foo/bar', "exists"); |
111 |
|
|
112 |
|
is_deeply($db->load_lookup( input => 'foo', key => 'bar' ), $l, 'load_lookup'); |
113 |
|
|
114 |
ok($db->save_lookup( database => 'baz', input => 'foo', key => 'bar', data => $l ), "save_lookup with database"); |
ok($db->save_lookup( database => 'baz', input => 'foo', key => 'bar', data => $l ), "save_lookup with database"); |
115 |
|
|
116 |
ok(-e $db->path . '/lookup/baz/foo/bar', "exists"); |
ok(-e $db->path . '/lookup/baz/foo/bar', "exists"); |
117 |
|
|
118 |
|
is_deeply($db->load_lookup( database => 'baz', input => 'foo', key => 'bar' ), $l, 'load_lookup'); |
119 |
|
|
120 |
undef $db; |
undef $db; |
121 |
|
|