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
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue