/[pub]/suikawiki/script/t/db-logical.t
Suika

Contents of /suikawiki/script/t/db-logical.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Sat Dec 6 02:18:36 2003 UTC (21 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
Error occurred while calculating annotation data.
New test

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Test;
5 use FindBin q($Bin);
6 BEGIN {plan tests => 5}
7 use SuikaWiki::DB::Logical;
8 use SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09;
9 use SuikaWiki::DB::Util::Error;
10
11 my $dir = $Bin.'/db.tmp';
12 mkdir $dir or die "$0: $dir: $!" unless -d $dir;
13
14 my $db = new SuikaWiki::DB::Logical;
15 my $subdb = new SuikaWiki::DB::FileSystem::SuikaWikiMetaInfo09
16 directory => $dir;
17 _set_prop_db $db
18 'test' => {-db => $subdb, -db_close => sub {
19 my %opt = @_;
20 local $Error::Depth = $Error::Depth + 1;
21 $opt{prop_info}->{-db}->close;
22 delete $opt{prop_info}->{-db};
23 }};
24
25 unshift @{$db->{event}->{error}}, sub {
26 my ($self, $event) = @_;
27 unless ({qw/fatal 1 stop 1 warn 1/}->{$event->{error}->{-def}->{level}}) {
28 warn "DEBUG: ". $event->{error}->stringify;
29 }
30 } if $^W;
31 unshift @{$subdb->{event}->{error}}, sub {
32 my ($self, $event) = @_;
33 unless ({qw/fatal 1 stop 1 warn 1/}->{$event->{error}->{-def}->{level}}) {
34 warn "DEBUG: test: ". $event->{error}->stringify;
35 }
36 } if $^W;
37
38 $db->set (test => ['Key'] => 'Value');
39 ok $db->get (test => ['Key']), 'Value';
40
41 ok $db->get (other => ['Key']), undef;
42 ok $db->get (test => ['other']), undef;
43
44 $db->set (test => ['Key', 'Subkey'] => 'SubValue');
45 ok $db->get (test => ['Key', 'Subkey']), 'SubValue';
46
47 $db->close;
48
49 my $file = $subdb->{directory}.$subdb->{prefix}.$subdb->__encode_base16 ('test')
50 .$subdb->{suffix};
51 undef $subdb;
52 undef $db;
53
54 ok -e $file, 1, 'Database is written on disk';
55 unlink $file or warn "$0: $file: $!";

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24