]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/hash-block.t
Add key file saving and refactor some stuff
[chaz/p5-File-KDBX] / t / hash-block.t
index 006f617e5af8defee7421f65ac2dd573db650f42..461ad55af90e16ecbd14a962c73c755fdbca4e3b 100644 (file)
@@ -8,10 +8,9 @@ use TestCommon qw(:no_warnings_test);
 
 use File::KDBX::Util qw(can_fork);
 use IO::Handle;
+use PerlIO::via::File::KDBX::HashBlock;
 use Test::More;
 
-BEGIN { use_ok 'PerlIO::via::File::KDBX::HashBlock' }
-
 {
     my $expected_plaintext = 'Tiny food from Spain!';
 
@@ -29,22 +28,6 @@ BEGIN { use_ok 'PerlIO::via::File::KDBX::HashBlock' }
     is $plaintext, $expected_plaintext, 'Hash-block just a little bit';
 }
 
-subtest 'Error handling' => sub {
-    pipe(my $read, my $write) or die "pipe failed: $!\n";
-
-    PerlIO::via::File::KDBX::HashBlock->push($read);
-
-    print $write 'blah blah blah';
-    close($write) or die "close failed: $!";
-
-    is $read->error, 0, 'Read handle starts out fine';
-    my $data = do { local $/; <$read> };
-    is $read->error, 1, 'Read handle can enter and error state';
-
-    like $PerlIO::via::File::KDBX::HashBlock::ERROR, qr/invalid block index/i,
-        'Error object is available';
-};
-
 SKIP: {
     skip 'Tests require fork' if !can_fork;
 
@@ -70,4 +53,20 @@ SKIP: {
     waitpid($pid, 0) or die "wait failed: $!\n";
 }
 
+subtest 'Error handling' => sub {
+    pipe(my $read, my $write) or die "pipe failed: $!\n";
+
+    PerlIO::via::File::KDBX::HashBlock->push($read);
+
+    print $write 'blah blah blah';
+    close($write) or die "close failed: $!";
+
+    is $read->error, 0, 'Read handle starts out fine';
+    my $data = do { local $/; <$read> };
+    is $read->error, 1, 'Read handle can enter and error state';
+
+    like $PerlIO::via::File::KDBX::HashBlock::ERROR, qr/invalid block index/i,
+        'Error object is available';
+};
+
 done_testing;
This page took 0.017551 seconds and 4 git commands to generate.