[Pkg-owncloud-commits] [owncloud-client] 418/484: Tests: Add a perl test for eml checksums #3235
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:38:15 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 1aa570326e7900efc0fd4a0fc88fd92fa818c159
Author: Christian Kamm <mail at ckamm.de>
Date: Wed Nov 25 12:46:45 2015 +0100
Tests: Add a perl test for eml checksums #3235
---
csync/tests/ownCloud/ownCloud/Test.pm | 28 +++++++----
csync/tests/ownCloud/t9.pl | 91 +++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 9 deletions(-)
diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index 821ffbd..cd83ec4 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -66,7 +66,7 @@ our %config;
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
- printInfo remoteFileId createShare removeShare assert
+ printInfo remoteFileProp remoteFileId createShare removeShare assert
configValue testDirUrl getToFileLWP getToFileCurl);
sub server
@@ -679,28 +679,38 @@ sub printInfo($)
$infoCnt++;
}
-sub remoteFileId($$)
+sub remoteFileProp($$)
{
my ($fromDir, $file) = @_;
my $fromUrl = testDirUrl() . $fromDir;
- my $id;
+ my $result;
if( my $r = $d->propfind( -url => $fromUrl, -depth => 1 ) ) {
if ( $r->is_collection ) {
# print "Collection\n";
foreach my $res ( $r->get_resourcelist->get_resources() ) {
- my $filename = $res->get_property("rel_uri");
- # print "OOOOOOOOOOOOOO $filename " . $res->get_property('id') . "\n";
- if( $file eq $filename || $filename eq $file . "/" ) {
- $id = $res->get_property('id') || "";
- }
+ my $filename = $res->get_property("rel_uri");
+ # print "OOOOOOOOOOOOOO $filename " . $res->get_property('id') . "\n";
+ if( $file eq $filename || $filename eq $file . "/" ) {
+ $result = $res;
+ }
}
} else {
# print "OOOOOOOOOOOOOOOOOOO " . $r->get_property("rel_uri");
- $id = $r->get_property('id') || "";
+ $result = $r;
}
}
+ return $result;
+}
+
+sub remoteFileId($$)
+{
+ my ($fromDir, $file) = @_;
+ my $id;
+ if( my $res = remoteFileProp($fromDir, $file) ) {
+ $id = $res->get_property('id') || "";
+ }
print "## ID of $file: $id\n";
return $id;
}
diff --git a/csync/tests/ownCloud/t9.pl b/csync/tests/ownCloud/t9.pl
new file mode 100755
index 0000000..9c2fb44
--- /dev/null
+++ b/csync/tests/ownCloud/t9.pl
@@ -0,0 +1,91 @@
+#!/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 Klaas Freitag <freitag at owncloud.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 t9, a tester for content checksums.\n";
+
+initTesting();
+
+printInfo( "Add some files to local");
+my $locDir = localDir();
+copy( "testfiles/test.txt", "$locDir/test.txt");
+copy( "testfiles/test.txt", "$locDir/test.eml");
+
+csync( );
+print "\nAssert local and remote dirs.\n";
+assertLocalAndRemoteDir( '', 0);
+
+# Get file properties before syncing again
+my $txtpropbefore = remoteFileProp("", "test.txt");
+my $emlpropbefore = remoteFileProp("", "test.eml");
+assert($txtpropbefore);
+assert($emlpropbefore);
+
+printInfo( "Touch local files");
+system( "touch $locDir/test.txt" );
+system( "touch $locDir/test.eml" );
+
+csync( );
+
+# Get file properties afterwards
+my $txtpropafter = remoteFileProp("", "test.txt");
+my $emlpropafter = remoteFileProp("", "test.eml");
+assert($txtpropafter);
+assert($emlpropafter);
+
+# The txt file is uploaded normally, etag and mtime differ
+assert($txtpropafter->get_property( "getetag" ) ne
+ $txtpropbefore->get_property( "getetag" ));
+assert($txtpropafter->get_property( "getlastmodified" ) ne
+ $txtpropbefore->get_property( "getlastmodified" ));
+# The eml was not uploaded, nothing differs
+assert($emlpropafter->get_property( "getetag" ) eq
+ $emlpropbefore->get_property( "getetag" ));
+assert($emlpropafter->get_property( "getlastmodified" ) eq
+ $emlpropbefore->get_property( "getlastmodified" ));
+
+printInfo( "Change content of eml file (but not size)");
+system( "sed -i -e 's/in/IN/' $locDir/test.eml" );
+
+csync( );
+
+# Get file properties afterwards
+my $emlpropchanged = remoteFileProp("", "test.eml");
+assert($emlpropchanged);
+assert($emlpropafter->get_property( "getetag" ) ne
+ $emlpropchanged->get_property( "getetag" ));
+assert($emlpropafter->get_property( "getlastmodified" ) ne
+ $emlpropchanged->get_property( "getlastmodified" ));
+
+# ==================================================================
+
+cleanup();
+
+# --
+
--
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