Skip to content

Commit

Permalink
test: Fix skipped tests under MSWin32
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Jun 10, 2024
1 parent 51212f5 commit ffc7cee
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions t/agent/tools/archive.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ use GLPI::Agent::Config;
use GLPI::Agent::Logger;
use GLPI::Agent::Tools::Archive;

if ($OSNAME eq 'MSWin32') {
plan skip_all => 'not working on Windows, but tested module not used on Windows';
}

my %archives = (
'tar' => {
file => "config.tar",
Expand Down Expand Up @@ -79,31 +75,35 @@ my $logger = GLPI::Agent::Logger->new(
)
);

foreach my $test (keys %archives) {
my $folder = tempdir(CLEANUP => 1);
my $file = "resources/archive/". $archives{$test}->{file};
;
SKIP: {
skip 'not working on Windows, but tested module not used on Windows', 4 * (scalar keys %archives)
if $OSNAME eq 'MSWin32';

my $archive;
lives_ok {
$archive = GLPI::Agent::Tools::Archive->new(
archive => $file,
type => $archives{$test}->{type} // "",
logger => $logger,
);
} "$test: archive object";
foreach my $test (keys %archives) {
my $folder = tempdir(CLEANUP => 1);
my $file = "resources/archive/". $archives{$test}->{file};

lives_ok {
$archive->extract(to => $folder);
} "$test: archive extract";
my $archive;
lives_ok {
$archive = GLPI::Agent::Tools::Archive->new(
archive => $file,
type => $archives{$test}->{type} // "",
logger => $logger,
);
} "$test: archive object";

$file = File::Spec->catfile($folder, $archives{$test}->{check});
ok(-e $file, "$test: extracted file");
lives_ok {
$archive->extract(to => $folder);
} "$test: archive extract";

if (-e $file) {
my $sha = Digest::SHA->new(256)->addfile($file);
is($sha->hexdigest, $archives{$test}->{sha256}, "$test: sha256 checked file");
} else {
fail "$test: sha256 checked file with missing file";
$file = File::Spec->catfile($folder, $archives{$test}->{check});
ok(-e $file, "$test: extracted file");

if (-e $file) {
my $sha = Digest::SHA->new(256)->addfile($file);
is($sha->hexdigest, $archives{$test}->{sha256}, "$test: sha256 checked file");
} else {
fail "$test: sha256 checked file with missing file";
}
}
}

0 comments on commit ffc7cee

Please sign in to comment.