[Pkg-owncloud-commits] [owncloud-client] 320/332: tests: Never stumble over an already existing test share dir.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:07:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit c3f8e099f463d4f78f109ee04f4b780e732bc3a2
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Aug 7 15:45:17 2014 +0200

    tests: Never stumble over an already existing test share dir.
---
 csync/tests/ownCloud/ownCloud/Test.pm | 30 ++++++++++++++++++++++++++++--
 csync/tests/ownCloud/t5.pl            | 10 +++++++---
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index dafa5c9..e47bffd 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);
- at EXPORT     = qw( initTesting createRemoteDir createLocalDir cleanup csync
+ at 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 b764e6d..dbc6015 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);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list