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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Thu Dec 4 07:23:22 2003 UTC (20 years, 11 months ago) by wakaba
Branch: MAIN
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 => 4}
7     use SuikaWiki::DB::FileSystem::YukiWikiDBNS;
8     use SuikaWiki::DB::Util::Error;
9    
10     my $dir = $Bin.'/db.tmp';
11     mkdir $dir or die "$0: $dir: $!" unless -d $dir;
12    
13     try {
14     my $db = new SuikaWiki::DB::FileSystem::YukiWikiDBNS
15     directory => $dir,
16     suffix => '.txt';
17    
18     $db->set (test => ['Key'] => 'Value');
19    
20     ok $db->get (test => ['Key']), 'Value';
21     ok $db->get (test => ['other']), undef;
22    
23     $db->set (test => ['Key', 'Sub'] => 'SubValue');
24     ok $db->get (test => ['Key', 'Sub']), 'SubValue';
25    
26     $db->close;
27    
28     undef $db;
29    
30     my $file = filename (['Key']);
31     ok -e $file, 1, 'Value is written on disk';
32     unlink $file or warn "$0: $file: $!";
33    
34     $file = filename (['Key', 'Sub']);
35     ok -e $file, 1, 'Namespaced value is written on disk';
36     unlink $file or warn "$0: $file: $!";
37    
38     $file = filename (['Key'], '.ns');
39     rmdir $file or warn "$0: $file: $!";
40     } catch SuikaWiki::DB::Util::Error with {
41     warn shift->stringify;
42     };
43    
44     sub filename ($;$) {
45     my ($key, $suffix) = (shift, shift || '.txt');
46     $dir.'/'.join ('.ns/', map {s/(.)/sprintf '%02X', ord $1/ges;$_} @$key).$suffix;
47     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24