Convert-Pheno
view release on metacpan or search on metacpan
lib/Convert/Pheno/IO/FileIO.pm view on Meta::CPAN
#########################
#########################
# SUBROUTINES FOR I/O #
#########################
#########################
sub _slurp_text {
my ($file) = @_;
if ( $file =~ /\.gz$/ ) {
# Gzipped text has to be decoded explicitly because Path::Tiny only
# covers plain files. Keep this logic isolated so plain-file semantics
# stay unchanged elsewhere.
my $fh = IO::Uncompress::Gunzip->new( $file, MultiStream => 1 )
or die "Cannot gunzip <$file>: $GunzipError";
binmode( $fh, ':encoding(UTF-8)' );
return do { local $/; <$fh> };
}
return path($file)->slurp_utf8;
}
t/25-json-bridge.t view on Meta::CPAN
}
}
}
}
)
);
is( $exit_ok, 0, 'bridge exits successfully for valid payload' );
is( $stderr_ok, q{}, 'bridge keeps stderr empty on success' );
my $decoded = eval { $json->decode($stdout_ok) };
ok( !$@, 'bridge returns valid JSON on success' );
is( $decoded->{id}, 'P0007500', 'bridge returns converted BFF payload' );
my ( $exit_missing_method, undef, $stderr_missing_method ) =
run_bridge( $json->encode( { data => {} } ) );
isnt( $exit_missing_method, 0, 'bridge fails when method is missing' );
like(
$stderr_missing_method,
qr/Payload must include string field 'method'/,
'bridge reports missing method clearly'
);
( run in 1.130 second using v1.01-cache-2.11-cpan-39bf76dae61 )