From 69ca50f0514a2bf1626005925c134cb7e268556e Mon Sep 17 00:00:00 2001 From: Shawn Boyette Date: Thu, 18 Jun 2009 18:23:37 +0000 Subject: [PATCH] test for existing DBMD file; die --- .../lib/Equinox/Migration/MapDrivenMARCXMLProc.pm | 2 ++ Equinox-Migration/t/03-MapDrivenMARCXMLProc.t | 3 +++ 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm b/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm index 46f973b..d78c528 100644 --- a/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm +++ b/Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm @@ -62,6 +62,8 @@ sub new { mods => \@mods ); # initialize datastore + die "Datastore file 'EMMXSSTORAGE.dbmd' already exists. Exiting.\n" + if (-e "EMMXSSTORAGE.dbmd"); $dstore = DBM::Deep->new( file => "EMMXSSTORAGE.dbmd", data_sector_size => 256 ); $reccount = 0; # next record ptr diff --git a/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t b/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t index dbab4cd..8c0d0f9 100644 --- a/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t +++ b/Equinox-Migration/t/03-MapDrivenMARCXMLProc.t @@ -49,6 +49,7 @@ is ($rec->{tags}[0]{tag}, 999, 'tag id 4'); is ($rec->{tags}[0]{uni}{a}, "FIC DEV", 'subfield value 4'); $rec = shift @{ $mp->{data}{recs} }; is ($rec, undef, 'no more records'); +$mp->DESTROY; # with map-01, 999$a and 999$q are captured. q only exists on the second # record; the others should the placeholder value of '' @@ -62,6 +63,7 @@ is ($rec->{tags}[0]{uni}{j}, undef, 'we shouldnt have captured this, even if it $rec = shift @{ $mp->{data}{recs} }; is ($rec->{tags}[0]{uni}{a}, "MYS 2", '999$a'); is ($rec->{tags}[0]{uni}{q}, "TEST", '999$q does exist here'); +$mp->DESTROY; # map-02 adds 999$x *not* as multi, producing a fatal error on the last record #eval { $mp = Equinox::Migration::MapDrivenMARCXMLProc->new( marcfile => 't/corpus/mdmp-0.txt', @@ -99,6 +101,7 @@ is_deeply ($rec->{tags}[0]{multi}{'x'}, ['FICTION','FICTION2','FICTION3','FICTIO '999$x - multi'); is ($rec->{tmap}{250}, undef, 'tag map test 2a'); is_deeply ($rec->{tmap}{999}, [0], 'tag map test 2b'); +$mp->DESTROY; # map-05 is map-04 with a "no digits" filter on 999$x $mp = Equinox::Migration::MapDrivenMARCXMLProc->new( marcfile => 't/corpus/mdmp-0.txt', -- 1.7.2.5