Removed final vestiges of misunderstandings
[dbsrgits/DBM-Deep.git] / t / 06_error.t
index 01297e3..ea39773 100644 (file)
@@ -5,50 +5,50 @@ $|++;
 use strict;
 use Test::More tests => 6;
 use Test::Exception;
+use t::common qw( new_fh );
 
 use_ok( 'DBM::Deep' );
 
-##
-# make sure you can clear the error state
-##
+my ($fh, $filename) = new_fh();
+
 ##
 # test a corrupted file
 ##
-open FH, '>t/test.db';
+open FH, ">$filename";
 print FH 'DPDB';
 close FH;
 throws_ok {
-    DBM::Deep->new( "t/test.db" );
-} qr/DBM::Deep: Corrupted file, no master index record/, "Fail if there's no master index record";
+    DBM::Deep->new( $filename );
+} qr/DBM::Deep: Old file version found/, "Fail if there's a bad header";
 
 {
-    unlink "t/test.db";
+    my ($fh, $filename) = new_fh();
     my %hash;
-    tie %hash, 'DBM::Deep', 't/test.db';
+    tie %hash, 'DBM::Deep', $filename;
     undef %hash;
 
     my @array;
     throws_ok {
-        tie @array, 'DBM::Deep', 't/test.db';
+        tie @array, 'DBM::Deep', $filename;
     } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie a hash file with an array";
 
     throws_ok {
-        DBM::Deep->new( file => 't/test.db', type => DBM::Deep->TYPE_ARRAY )
+        DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY )
     } qr/DBM::Deep: File type mismatch/, "Fail if we try and open a hash file with an array";
 }
 
 {
-    unlink "t/test.db";
+    my ($fh, $filename) = new_fh();
     my @array;
-    tie @array, 'DBM::Deep', 't/test.db';
+    tie @array, 'DBM::Deep', $filename;
     undef @array;
 
     my %hash;
     throws_ok {
-        tie %hash, 'DBM::Deep', 't/test.db';
+        tie %hash, 'DBM::Deep', $filename;
     } qr/DBM::Deep: File type mismatch/, "Fail if we try and tie an array file with a hash";
 
     throws_ok {
-        DBM::Deep->new( file => 't/test.db', type => DBM::Deep->TYPE_HASH )
+        DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_HASH )
     } qr/DBM::Deep: File type mismatch/, "Fail if we try and open an array file with a hash";
 }