mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 05:15:40 +03:00
t_recall.pl: add a test for the recall feature
This commit is contained in:
parent
9a02a0f3a8
commit
49fb37fefc
2 changed files with 80 additions and 1 deletions
|
@ -192,7 +192,6 @@ sub removeRemoteDir($;$)
|
||||||
my ($dir, $optionsRef) = @_;
|
my ($dir, $optionsRef) = @_;
|
||||||
|
|
||||||
my $url = testDirUrl() . $dir;
|
my $url = testDirUrl() . $dir;
|
||||||
|
|
||||||
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
|
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
|
||||||
$d->credentials( -url=> $owncloud, -realm=>"ownCloud",
|
$d->credentials( -url=> $owncloud, -realm=>"ownCloud",
|
||||||
-user=> $optionsRef->{user},
|
-user=> $optionsRef->{user},
|
||||||
|
@ -525,7 +524,9 @@ sub put_to_dir( $$;$ )
|
||||||
|
|
||||||
my $filename = $file;
|
my $filename = $file;
|
||||||
$filename =~ s/^.*\///;
|
$filename =~ s/^.*\///;
|
||||||
|
$filename =~ s/#/%23/g; # poor man's URI encoder
|
||||||
my $puturl = $targetUrl . $dir. $filename;
|
my $puturl = $targetUrl . $dir. $filename;
|
||||||
|
|
||||||
print "put_to_dir puts to $puturl\n";
|
print "put_to_dir puts to $puturl\n";
|
||||||
unless ($d->put( -local => $file, -url => $puturl )) {
|
unless ($d->put( -local => $file, -url => $puturl )) {
|
||||||
print " ### FAILED to put a single file!\n";
|
print " ### FAILED to put a single file!\n";
|
||||||
|
|
78
csync/tests/ownCloud/t_recall.pl
Executable file
78
csync/tests/ownCloud/t_recall.pl
Executable file
|
@ -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@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);
|
||||||
|
|
Loading…
Reference in a new issue