Apache2-Translation
view release on metacpan or search on metacpan
t/005provider-MMapDB.t view on Meta::CPAN
# -*- mode: cperl; cperl-indent-level: 2; cperl-continued-statement-offset: 2; indent-tabs-mode: nil -*-
use strict;
use warnings FATAL => 'all';
use Apache::Test (); # just load it to get the version
use version;
use Apache::Test (version->parse(Apache::Test->VERSION)>=version->parse('1.35')
? '-withtestmore' : ':withtestmore');
use Apache::TestUtil;
use Apache::TestUtil qw(t_catfile);
use Test::Deep;
use File::Basename 'dirname';
use File::Path ();
use Data::Dumper; $Data::Dumper::Useqq=1;
plan tests=>23;
#plan 'no_plan';
my $data=<<'EOD';
#xkey xuri xblock xorder xaction xnote
k1 u1 0 0 a note1
k1 u1 1 1 c note2
k1 u1 0 1 b
k1 u2 0 0 d note3
k1 u2 1 1 f
k1 u2 1 0 e note4
EOD
my $serverroot=Apache::Test::vars->{serverroot};
sub n {my @c=caller; $c[1].'('.$c[2].'): '.$_[0];}
my $conf=$serverroot.'/bdbenv.conf';
my $conf_notes=$serverroot.'/bdbenv.notes';
my $db=$serverroot.'/mmapdb';
{
my @wlog;
my $sw;
sub start_warnlog {
$sw=$SIG{__WARN__};
@wlog=();
$SIG{__WARN__}=sub {
push @wlog, "@_";
};
}
sub stop_warnlog {
$SIG{__WARN__}=$sw;
return @wlog;
}
}
######################################################################
## the real tests begin here ##
######################################################################
use Apache2::Translation::File;
use Apache2::Translation::MMapDB;
unlink $db, $db.'.lock';
File::Path::rmtree( $conf_notes );
t_mkdir( $conf_notes );
t_write_file( $conf, '' );
my $fo=Apache2::Translation::File->new
(
ConfigFile=>$conf,
NotesDir=>$conf_notes,
);
my $o=Apache2::Translation::MMapDB->new(FileName=>$db,
BaseKey=>'[qw/trans db/]');
my $ro=Apache2::Translation::MMapDB->new(FileName=>$db,
BaseKey=>'["trans","db"]',
( run in 0.729 second using v1.01-cache-2.11-cpan-80ec619307d )