Modify tests to use the automatic storage cleanup provided by WebGUI::Test.
Several tests previously leaked storage locations.
This commit is contained in:
parent
decde00451
commit
1a9da53abf
11 changed files with 18 additions and 11 deletions
|
|
@ -49,6 +49,7 @@ my $ad;
|
|||
my ($richAd, $textAd, $imageAd, $nonAd, $setAd);
|
||||
my $adSpace;
|
||||
my $imageStorage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($imageStorage);
|
||||
$imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
|
||||
|
||||
SKIP: {
|
||||
|
|
@ -219,7 +220,4 @@ END {
|
|||
if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') {
|
||||
$adSpace->delete;
|
||||
}
|
||||
if (defined $imageStorage and ref $imageStorage eq 'WebGUI::Storage') {
|
||||
$imageStorage->delete;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ is($gcAsPath->absolute($exportPath)->stringify, $litmus->absolute($exportPath)->
|
|||
|
||||
# now let's get tricky and test different file extensions
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage->getId);
|
||||
my $filename = 'somePerlFile_pl.txt';
|
||||
$storage->addFileFromScalar($filename, $filename);
|
||||
$session->user({userId=>3});
|
||||
|
|
@ -299,6 +300,7 @@ is($fileAsPath->absolute($exportPath)->stringify, $litmus->absolute($exportPath)
|
|||
|
||||
# test a different extension, the .foobar extension
|
||||
$storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage->getId);
|
||||
$filename = 'someFoobarFile.foobar';
|
||||
$storage->addFileFromScalar($filename, $filename);
|
||||
$properties = {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
##Create a storage location
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
|
||||
##Save the image to the location
|
||||
my $filename = "someScalarFile.txt";
|
||||
|
|
@ -84,6 +85,7 @@ $versionTag->commit;
|
|||
############################################
|
||||
|
||||
my $fileStorage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($fileStorage);
|
||||
$mocker->set_always('getValue', $fileStorage->getId);
|
||||
my $fileFormStorage = $asset->getStorageFromPost();
|
||||
isa_ok($fileFormStorage, 'WebGUI::Storage', 'Asset::File::getStorageFromPost');
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ $rectangle->setBackgroundColor('#0000FF');
|
|||
|
||||
##Create a storage location
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
|
||||
##Save the image to the location
|
||||
$rectangle->saveToStorageLocation($storage, 'blue.png');
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ my $product = $node->addChild({
|
|||
is($product->getThumbnailUrl(), '', 'Product with no image1 property returns the empty string');
|
||||
|
||||
my $image = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($image);
|
||||
$image->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'));
|
||||
|
||||
my $imagedProduct = $node->addChild({
|
||||
|
|
@ -61,6 +62,7 @@ ok($imagedProduct->getThumbnailUrl(), 'getThumbnailUrl is not empty');
|
|||
is($imagedProduct->getThumbnailUrl(), $image->getThumbnailUrl('lamp.jpg'), 'getThumbnailUrl returns the right path to the URL');
|
||||
|
||||
my $otherImage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($otherImage);
|
||||
$otherImage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('gooey.jpg'));
|
||||
|
||||
ok($imagedProduct->getThumbnailUrl($otherImage), 'getThumbnailUrl with an explicit storageId returns something');
|
||||
|
|
@ -89,8 +91,6 @@ is($imagedProduct->getConfiguredTitle, 'Bible - English', 'getConfiguredTitle is
|
|||
END {
|
||||
$product->purge;
|
||||
$imagedProduct->purge;
|
||||
$image->delete;
|
||||
$otherImage->delete;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ my $pathedFile = WebGUI::Test->getTestCollateralPath($filename);
|
|||
|
||||
# Use some test collateral to create a storage location and assign it to our article
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
|
||||
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ my $pathedFile = WebGUI::Test->getTestCollateralPath($filename);
|
|||
|
||||
# Use some test collateral to create a storage location and assign it to our article
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
|
||||
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
|
||||
|
||||
|
|
@ -87,6 +88,7 @@ isa_ok($duplicateArticle, 'WebGUI::Asset::Wobject::Article');
|
|||
|
||||
my $duplicateStorageId = $duplicateArticle->get("storageId");
|
||||
my $duplicateStorage = WebGUI::Storage->get($session,$duplicateStorageId);
|
||||
WebGUI::Test->storagesToDelete($duplicateStorage);
|
||||
my $duplicateFilename = $duplicateStorage->getFiles->[0];
|
||||
|
||||
is ($duplicateFilename, $filename, "duplicate method copies collateral");
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ sub setupTest {
|
|||
foreach my $testSet (@testSets) {
|
||||
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
my $filename = join '.', 'fileName', $testNum;
|
||||
$testSet->{filename} = $filename;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ my $spectreConf = WebGUI::Test->root . '/etc/spectre.conf';
|
|||
my $goodFile = 'The contents of this file are accessible';
|
||||
my $twoLines = "This file contains two lines of text\nThis is the second line";
|
||||
my $storage = WebGUI::Storage->createTemp($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
$storage->addFileFromScalar('goodFile', $goodFile);
|
||||
$storage->addFileFromScalar('twoLines', $twoLines);
|
||||
$storage->addFileFromScalar('unreadableFile', 'The contents of this file are not readable');
|
||||
|
|
@ -112,5 +113,4 @@ SKIP: {
|
|||
}
|
||||
|
||||
END {
|
||||
$storage->delete;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ $square->setBackgroundColor('#0000FF');
|
|||
|
||||
##Create a storage location
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($storage);
|
||||
|
||||
##Save the image to the location
|
||||
$square->saveToStorageLocation($storage, 'square.png');
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ ok ($uploadUrl, "uploadDir defined in config");
|
|||
####################################################
|
||||
|
||||
my $imageStore = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($imageStore);
|
||||
my $expectedFiles = ['.', '..'];
|
||||
cmp_bag($imageStore->getFiles(1), $expectedFiles, 'Starting with an empty storage object, no files in here except for . and ..');
|
||||
$imageStore->addFileFromScalar('.dotfile', 'dot file');
|
||||
|
|
@ -118,6 +119,7 @@ foreach my $extTest ( @{ $extensionTests } ) {
|
|||
WebGUI::Test->interceptLogging();
|
||||
|
||||
my $thumbStore = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($thumbStore);
|
||||
my $square = WebGUI::Image->new($session, 500, 500);
|
||||
$square->setBackgroundColor('#FF0000');
|
||||
$square->saveToStorageLocation($thumbStore, 'square.png');
|
||||
|
|
@ -168,6 +170,7 @@ like($WebGUI::Test::logger_error, qr/^Couldn't read image to check the size of i
|
|||
####################################################
|
||||
|
||||
my $imageCopy = $thumbStore->copy();
|
||||
WebGUI::Test->storagesToDelete($imageCopy);
|
||||
isa_ok($imageCopy, 'WebGUI::Storage', 'copy returns an object');
|
||||
cmp_bag(
|
||||
$imageCopy->getFiles(),
|
||||
|
|
@ -216,6 +219,7 @@ is($thumbStore->getThumbnailUrl('square.png'), $thumbStore->getUrl('thumb-square
|
|||
my $origMaxImageSize = $session->setting->get('maxImageSize');
|
||||
|
||||
my $sizeTest = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->storagesToDelete($sizeTest);
|
||||
|
||||
my $resizeTarget = 80;
|
||||
$session->setting->set('maxImageSize', 200 );
|
||||
|
|
@ -279,9 +283,4 @@ TODO: {
|
|||
}
|
||||
|
||||
END {
|
||||
foreach my $stor (
|
||||
$imageStore, $thumbStore, $imageCopy, $sizeTest,
|
||||
) {
|
||||
ref $stor eq "WebGUI::Storage" and $stor->delete;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue