test for existing DBMD file; die
authorShawn Boyette <sboyette@esilibrary.com>
Thu, 18 Jun 2009 18:23:37 +0000 (18:23 +0000)
committerShawn Boyette <sboyette@esilibrary.com>
Thu, 18 Jun 2009 18:23:37 +0000 (18:23 +0000)
Equinox-Migration/lib/Equinox/Migration/MapDrivenMARCXMLProc.pm
Equinox-Migration/t/03-MapDrivenMARCXMLProc.t

index 46f973b..d78c528 100644 (file)
@@ -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
index dbab4cd..8c0d0f9 100644 (file)
@@ -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',