tests: Never stumble over an already existing test share dir.

This commit is contained in:
Klaas Freitag 2014-08-07 15:45:17 +02:00
parent 6cb8134690
commit c3f8e099f4
2 changed files with 35 additions and 5 deletions

View file

@ -61,7 +61,7 @@ our $infoCnt = 1;
our %config;
@ISA = qw(Exporter);
@EXPORT = qw( initTesting createRemoteDir createLocalDir cleanup csync
@EXPORT = qw( initTesting createRemoteDir removeRemoteDir createLocalDir cleanup csync
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
@ -180,6 +180,32 @@ sub initLocalDir
mkdir ($localDir, 0777 );
}
sub removeRemoteDir($;$)
{
my ($dir, $optionsRef) = @_;
my $url = testDirUrl() . $dir;
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
$d->credentials( -url=> $owncloud, -realm=>"ownCloud",
-user=> $optionsRef->{user},
-pass=> $optionsRef->{passwd} );
if( $optionsRef->{url} ) {
$url = $optionsRef->{url} . $dir;
}
}
$d->open( $owncloud );
print $d->message . "\n";
my $re = $d->delete( $url );
if( $re == 0 ) {
print "Failed to remove directory <$url>:" . $d->message() ."\n";
}
return $re;
}
sub createRemoteDir(;$$)
{
my ($dir, $optionsRef) = @_;
@ -200,7 +226,7 @@ sub createRemoteDir(;$$)
my $re = $d->mkcol( $url );
if( $re == 0 ) {
print "Failed to create directory <$url>: $d->message() \n";
print "Failed to create directory <$url>: " . $d->message() ."\n";
exit 1;
}
$d->open( $url );

View file

@ -37,6 +37,13 @@ initTesting();
csync();
my $share_dir = "share_source";
my $sharee = { user => configValue('share_user'),
passwd => configValue('share_passwd'),
url => server() };
# first remove a possibly left over share dir.
printInfo( "Remove possibly left over share dir" );
removeRemoteDir( $share_dir, $sharee );
printInfo( "Create a share." );
my $shareId = createShare( $share_dir, 31 );
@ -44,9 +51,6 @@ print "Created share with id <$shareId>\n";
assert( $shareId > 0 );
my $sharee = { user => configValue('share_user'),
passwd => configValue('share_passwd'),
url => server() };
# put a couple of files into the shared directory in the sharer account
glob_put( 'sharing/*', $share_dir, $sharee);