Skip to content
Snippets Groups Projects
Commit 659bfca2 authored by Guillem Jover's avatar Guillem Jover
Browse files

test: Add Dpkg::File unit tests

parent d9215012
No related branches found
No related tags found
1 merge request!4Update crimson to version from bookworm
......@@ -279,6 +279,7 @@ test_data = \
t/Dpkg_Dist_Files/files-byhand \
t/Dpkg_Dist_Files/files-fragment-a \
t/Dpkg_Dist_Files/files-fragment-b \
t/Dpkg_File/slurp-me \
t/Dpkg_OpenPGP/package_1.0.orig.tar \
t/Dpkg_OpenPGP/package_1.0.orig.tar.asc \
t/Dpkg_OpenPGP/package_1.0.orig.tar.sig \
......
......@@ -16,12 +16,40 @@
use strict;
use warnings;
use Test::More tests => 1;
use Test::More tests => 4;
use Test::Dpkg qw(:paths);
BEGIN {
use_ok('Dpkg::File');
}
# TODO: Add actual test cases.
my $datadir = test_get_data_path();
my ($data, $data_ref, $data_fh);
$data = file_slurp("$datadir/slurp-me");
$data_ref = <<'DATA';
first line
next line
final line
DATA
is($data, $data_ref, 'slurped data');
open $data_fh, '<', "$datadir/slurp-me"
or die "cannot open $datadir/slurp-me for reading: $!";
my $discard = <$data_fh>;
$data = file_slurp($data_fh);
close $data_fh;
$data_ref = <<'DATA';
next line
final line
DATA
is($data, $data_ref, 'slurped partial data');
$data = undef;
eval {
$data = file_slurp("$datadir/non-existent");
};
ok($@, 'cannot slurp missing file');
1;
first line
next line
final line
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment