X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-File-KDBX;a=blobdiff_plain;f=t%2Fhash-block.t;h=461ad55af90e16ecbd14a962c73c755fdbca4e3b;hp=006f617e5af8defee7421f65ac2dd573db650f42;hb=1b913e5c8826cae2355b0076ec5701aa3ce63c63;hpb=b30990a507ef30b6f5b6fcb799a2759632c77ff0 diff --git a/t/hash-block.t b/t/hash-block.t index 006f617..461ad55 100644 --- a/t/hash-block.t +++ b/t/hash-block.t @@ -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;