/[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.2 - (hide annotations) (download) (as text)
Sat Dec 6 02:18:36 2003 UTC (20 years, 11 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
Changes since 1.1: +13 -10 lines
File MIME type: application/x-troff
New test

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24