/[pub]/suikawiki/script/t/db-fs-lf.t
Suika

Contents of /suikawiki/script/t/db-fs-lf.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Fri Apr 2 04:29:46 2004 UTC (20 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
File MIME type: application/x-troff
New tests

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use warnings;
4     use Test;
5     use FindBin q($Bin);
6     BEGIN {plan tests => 6}
7     use SuikaWiki::DB::FileSystem::LeafFile;
8    
9     my $dir = $Bin.'/db.tmp';
10     #mkdir $dir or die "$0: $dir: $!" unless -d $dir;
11    
12     sub filename ($;$) {
13     my ($key, $suffix) = (shift, shift || '.txt');
14     $dir.'/'.join ('.ns/', map {s/(.)/sprintf '%02X', ord $1/ges;$_} @$key).$suffix;
15     }
16    
17     my $db = new SuikaWiki::DB::FileSystem::LeafFile
18     base_directory => $dir,
19     directory_suffix => '.ns',
20     file_suffix => '.txt';
21    
22     unshift @{$db->{event}->{error}}, sub {
23     my ($self, $event) = @_;
24     unless ({qw/fatal 1 stop 1 warn 1/}->{$event->{error}->{-def}->{level}}) {
25     warn "DEBUG: ". $event->{error}->stringify;
26     }
27     } if $^W;
28    
29     $db->set (test => ['Key'] => 'Value');
30    
31     ok $db->get (test => ['Key']), 'Value';
32     ok $db->get (test => ['other']), undef;
33    
34     $db->set (test => ['Key'] => 'Value2');
35     ok $db->get (test => ['Key']), 'Value2';
36    
37     $db->set (test => ['Key', 'Sub'] => 'SubValue');
38     ok $db->get (test => ['Key', 'Sub']), 'SubValue';
39    
40     $db->close;
41    
42     undef $db;
43    
44     my $file = filename (['Key']);
45     ok -e $file, 1, 'Value is written on disk';
46     unlink $file or warn "$0: $file: $!";
47    
48     $file = filename (['Key', 'Sub']);
49     ok -e $file, 1, 'Namespaced value is written on disk';
50     unlink $file or warn "$0: $file: $!";
51    
52     $file = filename (['Key'], '.ns');
53     rmdir $file or warn "$0: $file: $!";
54    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24