diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm index dafa5c9c0..e47bffd14 100644 --- a/csync/tests/ownCloud/ownCloud/Test.pm +++ b/csync/tests/ownCloud/ownCloud/Test.pm @@ -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 ); diff --git a/csync/tests/ownCloud/t5.pl b/csync/tests/ownCloud/t5.pl index b764e6d79..dbc60159f 100755 --- a/csync/tests/ownCloud/t5.pl +++ b/csync/tests/ownCloud/t5.pl @@ -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);