#!/usr/local/bin/perl -w
=head1 NAME
01revmapdb_sdbm.t - testing of VCP::RevMapDB::sdbm
=cut
use strict;
use Carp;
use Test;
use File::Path;
use VCP::Debug qw( enable_debug );
use VCP::RevMapDB::sdbm;
enable_debug( split /,/, $ENV{VCPDEBUG} ) if defined $ENV{VCPDEBUG} ;
my $t = -d 't' ? 't/' : '' ;
my $db_loc = "${t}01revmapdb_sdbm";
rmtree [$db_loc] or die "$! unlinking $db_loc" if -e $db_loc;
my $db;
my @tests = (
sub {
$db = VCP::RevMapDB::sdbm->new( StoreLoc => $db_loc );
ok $db;
},
sub {
ok ! -e $db_loc;
},
sub {
$db->open_db;
ok scalar glob "$db_loc/*db*";
},
sub {
$db->set( a => qw( foo bar ) );
ok join( ",", $db->get( "a" ) ), "foo,bar";
},
sub {
$db->close_db;
ok scalar glob "$db_loc/*db*";
},
sub {
$db->open_db;
ok scalar glob "$db_loc/*db*";
},
sub {
ok join( ",", $db->get( "a" ) ), "foo,bar";
},
sub {
$db->delete_db;
ok ! -e $db_loc;
},
sub {
$db->open_db;
ok scalar glob "$db_loc/*db*";
},
sub {
$db->delete_db;
ok ! -e $db_loc;
},
sub {
rmtree [$db_loc] or warn "$! unlinking $db_loc" if -e $db_loc;
ok 1;
},
) ;
plan tests => scalar( @tests ) ;
$_->() for @tests ;