don't modify test file
This commit is contained in:
parent
361f60c483
commit
9996f687d9
1 changed files with 11 additions and 8 deletions
|
|
@ -24,6 +24,9 @@ use WebGUI::Asset::Wobject::Shelf;
|
||||||
use WebGUI::AssetHelper::Product::ImportCSV;
|
use WebGUI::AssetHelper::Product::ImportCSV;
|
||||||
use Test::MockObject::Extends;
|
use Test::MockObject::Extends;
|
||||||
use WebGUI::Fork;
|
use WebGUI::Fork;
|
||||||
|
use File::Temp;
|
||||||
|
use File::Copy;
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
|
|
@ -75,23 +78,23 @@ SKIP: {
|
||||||
skip 'Root will cause this test to fail since it does not obey file permissions', 3
|
skip 'Root will cause this test to fail since it does not obey file permissions', 3
|
||||||
if $< == 0;
|
if $< == 0;
|
||||||
|
|
||||||
my $originalChmod = (stat $productsFile)[2];
|
my (undef, $productsTempFile) = File::Temp::tempfile('productTableXXXX', OPEN => 0, TMPDIR => 1, SUFFIX => '.csv');
|
||||||
chmod oct(0000), $productsFile;
|
File::Copy::copy($productsFile, $productsTempFile);
|
||||||
|
|
||||||
eval { $shelf->importProducts($productsFile); };
|
chmod oct(0000), $productsTempFile;
|
||||||
|
|
||||||
|
eval { $shelf->importProducts($productsTempFile); };
|
||||||
$e = Exception::Class->caught();
|
$e = Exception::Class->caught();
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidFile', 'importProducts: error handling for file that cannot be read');
|
isa_ok($e, 'WebGUI::Error::InvalidFile', 'importProducts: error handling for file that cannot be read') || skip 'invalid error thrown', 2;
|
||||||
is($e->error, 'File is not readable', 'importProducts: error handling for file that that cannot be read');
|
is($e->error, 'File is not readable', 'importProducts: error handling for file that that cannot be read');
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$e,
|
$e,
|
||||||
methods(
|
methods(
|
||||||
brokenFile => $productsFile,
|
brokenFile => $productsTempFile,
|
||||||
),
|
),
|
||||||
'importProducts: error handling for file that that cannot be read',
|
'importProducts: error handling for file that that cannot be read',
|
||||||
);
|
);
|
||||||
|
unlink $productsTempFile;
|
||||||
chmod $originalChmod, $productsFile;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $failure=0;
|
my $failure=0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue