[Pkg-owncloud-commits] [owncloud-client] 89/175: t_recall.pl: add a test for the recall feature

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:30 UTC 2015


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 49fb37fefcb640fddeb84c4d1ed3e3526f97a81c
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Fri May 15 17:00:46 2015 +0200

    t_recall.pl: add a test for the recall feature
---
 csync/tests/ownCloud/ownCloud/Test.pm |  3 +-
 csync/tests/ownCloud/t_recall.pl      | 78 +++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index 5b24d0b..821ffbd 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -192,7 +192,6 @@ sub removeRemoteDir($;$)
     my ($dir, $optionsRef) = @_;
 
     my $url = testDirUrl() . $dir;
-
     if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
 	$d->credentials( -url=> $owncloud, -realm=>"ownCloud",
 			 -user=> $optionsRef->{user},
@@ -525,7 +524,9 @@ sub put_to_dir( $$;$ )
 
     my $filename = $file;
     $filename =~ s/^.*\///;
+    $filename =~ s/#/%23/g;  # poor man's URI encoder
     my $puturl = $targetUrl . $dir. $filename;
+
     print "put_to_dir puts to $puturl\n";
     unless ($d->put( -local => $file, -url => $puturl )) {
       print "  ### FAILED to put a single file!\n";
diff --git a/csync/tests/ownCloud/t_recall.pl b/csync/tests/ownCloud/t_recall.pl
new file mode 100755
index 0000000..6c5ca00
--- /dev/null
+++ b/csync/tests/ownCloud/t_recall.pl
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+#
+# Test script for the ownCloud module of csync.
+# This script requires a running ownCloud instance accessible via HTTP.
+# It does quite some fancy tests and asserts the results.
+#
+# Copyright (C) by Olivier Goffart <ogoffart at woboq.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+use lib ".";
+
+
+use File::Copy;
+use ownCloud::Test;
+
+use strict;
+
+print "Hello, this is t_recall, a tester for the recall feature\n";
+
+initTesting();
+
+printInfo( "Syncing two files with the same name that differ with case" );
+
+#create some files
+my $tmpdir = "/tmp/t_recall/";
+mkdir($tmpdir);
+createLocalFile( $tmpdir . "file1.dat", 100 );
+createLocalFile( $tmpdir . "file2.dat", 150 );
+createLocalFile( $tmpdir . "file3.dat", 110 );
+createLocalFile( $tmpdir . "file4.dat", 170 );
+
+#put them in some directories
+createRemoteDir( "dir" );
+glob_put( "$tmpdir/*", "dir" );
+
+csync();
+
+assertLocalAndRemoteDir( '', 0);
+
+
+
+printInfo( "Testing with a .sys.admin#recall#" );
+system("echo 'dir/file2.dat' > ". $tmpdir . ".sys.admin\#recall\#");
+system("echo 'dir/file3.dat' >> ". $tmpdir . ".sys.admin\#recall\#");
+glob_put( "$tmpdir/.sys.admin\#recall\#", "" );
+
+csync();
+
+#test that the recall files have been created
+assert( -e glob(localDir().'dir/file2_.sys.admin#recall#-*.dat' ) );
+assert( -e glob(localDir().'dir/file3_.sys.admin#recall#-*.dat' ) );
+
+#Remove the recall file
+unlink(localDir() . ".sys.admin#recall#");
+
+# 2 sync necessary for the recall to be uploaded
+csync();
+
+assertLocalAndRemoteDir( '', 0);
+
+
+cleanup();
+system("rm -r " . $tmpdir);
+

-- 
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