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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Sun Apr 25 07:06:50 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
LeafProp database module added; content_prop implemented; Media type property implemented

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::LeafProp;
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::LeafProp
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     my $v = $db->get (test => ['Key']);
30     ok $v->get_attribute_value ('V1'), undef;
31    
32     $v->set_attribute (V1 => 'value1');
33     $db->set (test => ['Key'] => $v);
34     ok $db->get (test => ['Key'])->get_attribute_value ('V1'), 'value1';
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    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24