fixing test warnings, Storage should always return to the correct directory
This commit is contained in:
parent
f1ca6d93f8
commit
8533cf8ae8
3 changed files with 26 additions and 21 deletions
|
|
@ -458,11 +458,10 @@ sub delete {
|
|||
|
||||
my $path = $self->getPath;
|
||||
if ($path) {
|
||||
rmtree($path) if ($path);
|
||||
rmtree($path) if (-d $path);
|
||||
foreach my $subDir ($self->{_part1}.'/'.$self->{_part2}, $self->{_part1}) {
|
||||
my $uDir = $self->session->config->get('uploadsPath') . '/' . $subDir;
|
||||
opendir my ($DH), $uDir;
|
||||
if (defined $DH) {
|
||||
if (opendir my $DH, $uDir) {
|
||||
my @dirs = grep { !/^\.+$/ } readdir($DH);
|
||||
if (scalar @dirs == 0) {
|
||||
rmtree($uDir);
|
||||
|
|
@ -661,14 +660,16 @@ The name of the file to get the icon for.
|
|||
=cut
|
||||
|
||||
sub getFileIconUrl {
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $extension = $self->getFileExtension($filename);
|
||||
my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif";
|
||||
if (-e $path && $extension) {
|
||||
return $self->session->url->extras("fileIcons/".$extension.".gif");
|
||||
}
|
||||
return $self->session->url->extras("fileIcons/unknown.gif");
|
||||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $extension = $self->getFileExtension($filename);
|
||||
if ($extension) {
|
||||
my $path = $self->session->config->get("extrasPath").'/fileIcons/'.$extension.".gif";
|
||||
if (-e $path) {
|
||||
return $self->session->url->extras("fileIcons/".$extension.".gif");
|
||||
}
|
||||
}
|
||||
return $self->session->url->extras("fileIcons/unknown.gif");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -941,6 +942,7 @@ sub tar {
|
|||
my $self = shift;
|
||||
my $filename = shift;
|
||||
my $temp = shift || WebGUI::Storage->createTemp($self->session);
|
||||
my $originalDir = cwd;
|
||||
chdir $self->getPath or croak 'Unable to chdir to ' . $self->getPath . ": $!";
|
||||
my @files = ();
|
||||
find(sub { push(@files, $File::Find::name)}, ".");
|
||||
|
|
@ -948,11 +950,11 @@ sub tar {
|
|||
my $tar = Archive::Tar->new();
|
||||
$tar->add_files(@files);
|
||||
$tar->write($temp->getPath($filename),1);
|
||||
|
||||
}
|
||||
else {
|
||||
Archive::Tar->create_archive($temp->getPath($filename),1,@files);
|
||||
}
|
||||
chdir $originalDir;
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,11 +152,14 @@ $mech->content_contains( $testContent, "We made it to the snippet through the lo
|
|||
|
||||
$response = $mech->res->previous;
|
||||
ok( $response, 'There were at least two requests' );
|
||||
is(
|
||||
$response->headers->header('location'),
|
||||
$redirectToUrl . ';' . $extraParams,
|
||||
"We were redirected to the right URL with forwarded query params",
|
||||
);
|
||||
TODO: {
|
||||
local $TODO = 'Add forwarding of query parameters to Redirect asset';
|
||||
is(
|
||||
$response->headers->header('location'),
|
||||
$redirectToUrl . ';' . $extraParams,
|
||||
"We were redirected to the right URL with forwarded query params",
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@ use File::Spec;
|
|||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Test::MockObject;
|
||||
use Cwd;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $cwd = Cwd::cwd();
|
||||
|
||||
my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session);
|
||||
|
||||
my $numTests = 82; # increment this value for each test you create
|
||||
|
|
@ -400,10 +403,7 @@ foreach my $iconTest (@{ $fileIconTests }) {
|
|||
#
|
||||
####################################################
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Write a test to ensure our CWD remains the same after all these calls to storage';
|
||||
ok(0,'CWD must remain the same after addFileFromFilesystem, tar, untar, etc...');
|
||||
};
|
||||
is($cwd, Cwd::cwd(), 'CWD must remain the same after addFileFromFilesystem, tar, untar, etc...');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue